This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Checking out PR4483 (constant overflow on PPC, problems compiling Linux kernel)
- From: Richard Henderson <rth at redhat dot com>
- To: Corey Minyard <minyard at acm dot org>
- Cc: David Edelsohn <dje at watson dot ibm dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 30 Nov 2001 17:29:33 -0800
- Subject: Re: Checking out PR4483 (constant overflow on PPC, problems compiling Linux kernel)
- References: <200111290234.VAA27602@makai.watson.ibm.com> <3C068792.7080400@acm.org>
On Thu, Nov 29, 2001 at 01:08:02PM -0600, Corey Minyard wrote:
> RCS file: /cvs/gcc/gcc/gcc/recog.c,v
> retrieving revision 1.133
> diff -u -p -r1.133 recog.c
> --- recog.c 2001/11/02 10:52:08 1.133
> +++ recog.c 2001/11/29 19:03:05
> @@ -512,7 +512,8 @@ validate_replace_rtx_1 (loc, from, to, o
> separated from this function. */
> if (GET_CODE (XEXP (x, 1)) == CONST_INT)
> validate_change (object, loc,
> - plus_constant (XEXP (x, 0), INTVAL (XEXP (x, 1))), 1);
> + simplify_gen_binary
> + (PLUS, GET_MODE (x), XEXP (x, 0), XEXP (x, 1)), 1);
Ok.
> diff -u -p -r1.86 simplify-rtx.c
> --- simplify-rtx.c 2001/11/14 13:51:10 1.86
> +++ simplify-rtx.c 2001/11/29 19:03:12
> @@ -1276,7 +1276,8 @@ simplify_binary_operation (code, mode, o
>
> /* Don't let a relocatable value get a negative coeff. */
> if (GET_CODE (op1) == CONST_INT && GET_MODE (op0) != VOIDmode)
> - return plus_constant (op0, - INTVAL (op1));
> + return plus_constant (op0,
> + trunc_int_for_mode (- INTVAL (op1), mode));
On cursory glance, I see at least 3 other examples of this bug
just in simplify-rtx.c. I suspect this is all over the place. :-(
There was a suggestion at some point to add a plus_constant_mode,
but I guess nothing ever happened there. I don't know if it's
better or worse with an implicit truncation. In some other case
we could just as well use
simplify_gen_binary (MINUS, mode, op0, op1);
but here, that's exactly what we're trying to simplify. ;-)
I think I'd rather you used
simplify_gen_binary (PLUS, mode, op0, neg_const_int (mode, op1))
with
rtx
neg_const_int (mode, i)
enum machine_mode mode;
rtx i;
{
return GEN_INT (trunc_int_for_mode (- INTVAL (i), mode));
}
defined somewhere in simplify-rtx.c and prototyped with the rest
of the functions from that file. That sequence is common enough
I think a function-let will turn out go be worthwhile in the end.
(Fixing these in simplify_plus_minus at the same time encouraged.)
My reasoning here is that if you've got
code = PLUS
mode = SImode
op0 = (plus:SI (reg:SI 10101) (const_int 1))
op1 = (const_int 0x7fffffff)
then plus_constant isn't going to do the right thing. I don't
know for sure if simplify_gen_binary will at the moment either,
but at least it has the proper information (i.e. the mode) and
can be fixed relatively easily.
r~