This is the mail archive of the gcc-patches@gcc.gnu.org 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]
Other format: [Raw text]

Re: Trim surplus zero extends


On Sun, Mar 24, 2002 at 09:59:39AM +1030, Alan Modra wrote:
> No, it's entirely my fault.  I have a love letter from the regression
> tester about it too..  I'll see about fixing the problem tomorrow.

Hum, maybe I took the blame too quickly. :)  It is true that my patch
unmasked other bugs.

The following patch stops
(compare (ashiftrt:SI (ashift:SI (subreg:SI (reg:QI) 0)
                                 (const_int 24))
                      (const_int 24))
         (const_int 255))

being directly converted (code patched by first hunk) to
(compare (subreg:SI (reg:QI) 0)
         (const_int 255))

or (via code patched by third hunk) to
(compare (ashift:SI (subreg:SI (reg:QI) 0)
                    (const_int 24))
         (const_int 0xff000000))

The problem being that these conversions ignore the sign copying done
by ASHIFTRT.

	* combine.c (simplify_comparison <ASHIFTRT, LSHIFTRT>): Correct
	test for overflow of constant.

Bootstrapping 3.1 powerpc-linux again (and this time I'll be a little
more careful looking at regression test results!)

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

Index: gcc/combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.275
diff -u -p -r1.275 combine.c
--- combine.c	2002/03/23 01:53:44	1.275
+++ combine.c	2002/03/24 23:40:34
@@ -10843,9 +10843,9 @@ simplify_comparison (code, pop0, pop1)
 	      && XEXP (op0, 1) == XEXP (XEXP (op0, 0), 1)
 	      && (tmode = mode_for_size (mode_width - INTVAL (XEXP (op0, 1)),
 					 MODE_INT, 1)) != BLKmode
-	      && ((unsigned HOST_WIDE_INT) const_op <= GET_MODE_MASK (tmode)
-		  || ((unsigned HOST_WIDE_INT) -const_op
-		      <= GET_MODE_MASK (tmode))))
+	      && (((unsigned HOST_WIDE_INT) const_op
+		   + (GET_MODE_MASK (tmode) >> 1) + 1)
+		  <= GET_MODE_MASK (tmode)))
 	    {
 	      op0 = gen_lowpart_for_combine (tmode, XEXP (XEXP (op0, 0), 0));
 	      continue;
@@ -10862,9 +10862,9 @@ simplify_comparison (code, pop0, pop1)
 	      && XEXP (op0, 1) == XEXP (XEXP (XEXP (op0, 0), 0), 1)
 	      && (tmode = mode_for_size (mode_width - INTVAL (XEXP (op0, 1)),
 					 MODE_INT, 1)) != BLKmode
-	      && ((unsigned HOST_WIDE_INT) const_op <= GET_MODE_MASK (tmode)
-		  || ((unsigned HOST_WIDE_INT) -const_op
-		      <= GET_MODE_MASK (tmode))))
+	      && (((unsigned HOST_WIDE_INT) const_op
+		   + (GET_MODE_MASK (tmode) >> 1) + 1)
+		  <= GET_MODE_MASK (tmode)))
 	    {
 	      rtx inner = XEXP (XEXP (XEXP (op0, 0), 0), 0);
 	      rtx add_const = XEXP (XEXP (op0, 0), 1);
@@ -10889,9 +10889,12 @@ simplify_comparison (code, pop0, pop1)
 	      && mode_width <= HOST_BITS_PER_WIDE_INT
 	      && (nonzero_bits (XEXP (op0, 0), mode)
 		  & (((HOST_WIDE_INT) 1 << INTVAL (XEXP (op0, 1))) - 1)) == 0
-	      && (const_op == 0
-		  || (floor_log2 (const_op) + INTVAL (XEXP (op0, 1))
-		      < mode_width)))
+	      && (((unsigned HOST_WIDE_INT) const_op
+		   + (GET_CODE (op0) != LSHIFTRT
+		      ? ((GET_MODE_MASK (mode) >> INTVAL (XEXP (op0, 1)) >> 1)
+			 + 1)
+		      : 0))
+		  <= GET_MODE_MASK (mode) >> INTVAL (XEXP (op0, 1))))
 	    {
 	      /* If the shift was logical, then we must make the condition
 		 unsigned.  */


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