This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[ping] Re: m32c: pointer math vs sizetype again
- From: DJ Delorie <dj at redhat dot com>
- To: richard dot guenther at gmail dot com, gcc at gcc dot gnu dot org
- Date: Wed, 12 Nov 2008 11:40:56 -0500
- Subject: [ping] Re: m32c: pointer math vs sizetype again
- References: <200809192352.m8JNq7Xs003011@greed.delorie.com> <200809302220.m8UMKIPj008507@greed.delorie.com> <84fc9c000810011511g56d55554oc1321be55bec411f@mail.gmail.com> <200810012243.m91MhdlG028543@greed.delorie.com> <84fc9c000810020212t2b910f2fi9ebc27bacd4ff4d@mail.gmail.com> <200810021622.m92GMHJK017096@greed.delorie.com> <200810021850.m92Ioexf021620@greed.delorie.com> <84fc9c000810021409rf3f352ak83d2db6520e6fc63@mail.gmail.com> <200810022137.m92LbIr0028916@greed.delorie.com>
Ping? Is this the right thing to do? I'd like to get this (and a few
other m32c bugs) resolved before the next release.
> This seems to work, with a suitable extendhipsi2 pattern for m32c:
>
> Index: expr.c
> ===================================================================
> --- expr.c (revision 140759)
> +++ expr.c (working copy)
> @@ -8455,12 +8459,34 @@ expand_expr_real_1 (tree exp, rtx target
> if (modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
> op0 = force_operand (op0, target);
> return REDUCE_BIT_FIELD (op0);
> }
> }
>
> + if (code == POINTER_PLUS_EXPR
> + || TYPE_PRECISION (TREE_OPERAND (exp, 1)) < TYPE_PRECISION (TREE_OPERAND (exp, 0)))
> + {
> + rtx reg;
> + enum machine_mode imode, omode;
> +
> + expand_operands (TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1),
> + subtarget, &op0, &op1, 0);
> +
> + if (op0 == const0_rtx)
> + return op1;
> + if (op1 == const0_rtx)
> + return op0;
> +
> + imode = GET_MODE (op1);
> + omode = GET_MODE (op0);
> + reg = gen_reg_rtx (omode);
> + emit_move_insn (reg, gen_rtx_fmt_e (SIGN_EXTEND, omode, op1));
> + op1 = reg;
> + goto binop2;
> + }
> +
> /* No sense saving up arithmetic to be done
> if it's all in the wrong mode to form part of an address.
> And force_operand won't know whether to sign-extend or
> zero-extend. */
> if ((modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER)
> || mode != ptr_mode)
>