This is the mail archive of the
mailing list for the GCC project.
[PATCH] combine.c CONST_INT MULT->ASHIFT must be positive
- To: gcc-patches at gcc dot gnu dot org
- Subject: [PATCH] combine.c CONST_INT MULT->ASHIFT must be positive
- From: David Edelsohn <dje at watson dot ibm dot com>
- Date: Fri, 13 Jul 2001 00:48:41 -0400
While fixing some exact_log2 bugs in the PowerPC port, I stumbled
upon a similar bug in combine.c. try_combine attempts to substitute an
arithmetic shift for a multiplication by a power-of-2 CONST_INT.
exact_log2_wide specifically says that its argument is considered
Now consider (const_int -2147483648 [0x80000000]) as an argument.
One needs to ensure that the argument to exact_log2 is positive because
CONST_INT inherently is signed.
* combine.c (try_combine): Ensure const_int pow2 is positive.
RCS file: /cvs/gcc/egcs/gcc/combine.c,v
retrieving revision 22.214.171.124
diff -c -p -5 -r126.96.36.199 combine.c
*** combine.c 2001/06/09 19:22:25 188.8.131.52
--- combine.c 2001/07/13 04:35:44
*************** try_combine (i3, i2, i1, new_direct_jump
*** 2236,2245 ****
--- 2236,2246 ----
/* If *SPLIT is a (mult FOO (const_int pow2)), convert it to
an ASHIFT. This can occur if it was inside a PLUS and hence
appeared to be a memory address. This is a kludge. */
if (split_code == MULT
&& GET_CODE (XEXP (*split, 1)) == CONST_INT
+ && INTVAL (XEXP (*split, 1)) > 0
&& (i = exact_log2 (INTVAL (XEXP (*split, 1)))) >= 0)
SUBST (*split, gen_rtx_combine (ASHIFT, split_mode,
XEXP (*split, 0), GEN_INT (i)));
/* Update split_code because we may not have a multiply