This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] combine.c CONST_INT MULT->ASHIFT must be positive

	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.

Index: combine.c
RCS file: /cvs/gcc/egcs/gcc/combine.c,v
retrieving revision
diff -c -p -5 -r1.183.2.6 combine.c
*** combine.c	2001/06/09 19:22:25
--- 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]