]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
combine.c (simplify_comparison): Convert (ne (and (lshiftrt (xor X CST) Y) 1) 0)...
authorKazu Hirata <kazu@cs.umass.edu>
Sun, 14 Sep 2003 18:31:13 +0000 (18:31 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Sun, 14 Sep 2003 18:31:13 +0000 (18:31 +0000)
* combine.c (simplify_comparison): Convert
(ne (and (lshiftrt (xor X CST) Y) 1) 0) into
(eq (and (lshiftrt X Y) 1) 0).

From-SVN: r71385

gcc/ChangeLog
gcc/combine.c

index 887e10dfef934831af327efe5b9f2eca07899011..bf770b8c9d376bc19b42b14caee6320356c08d63 100644 (file)
@@ -1,3 +1,9 @@
+2003-09-14  Kazu Hirata  <kazu@cs.umass.edu>
+
+       * combine.c (simplify_comparison): Convert
+       (ne (and (lshiftrt (xor X CST) Y) 1) 0) into
+       (eq (and (lshiftrt X Y) 1) 0).
+
 2003-09-14  Kazu Hirata  <kazu@cs.umass.edu>
 
        * alias.c: Follow spelling conventions.
index 2567ca9b2d719c9cfa18c9f14c705c4204e32dbf..c18c36e80917c4ba7f2351a1a77047e9990b7949 100644 (file)
@@ -10983,19 +10983,30 @@ simplify_comparison (enum rtx_code code, rtx *pop0, rtx *pop1)
            }
 
          /* Convert (ne (and (lshiftrt (not X)) 1) 0) to
-            (eq (and (lshiftrt X) 1) 0).  */
+            (eq (and (lshiftrt X) 1) 0).
+            Also handle the case where (not X) is expressed using xor.  */
          if (const_op == 0 && equality_comparison_p
              && XEXP (op0, 1) == const1_rtx
-             && GET_CODE (XEXP (op0, 0)) == LSHIFTRT
-             && GET_CODE (XEXP (XEXP (op0, 0), 0)) == NOT)
-           {
-             op0 = simplify_and_const_int
-               (op0, mode,
-                gen_rtx_LSHIFTRT (mode, XEXP (XEXP (XEXP (op0, 0), 0), 0),
-                                  XEXP (XEXP (op0, 0), 1)),
-                (HOST_WIDE_INT) 1);
-             code = (code == NE ? EQ : NE);
-             continue;
+             && GET_CODE (XEXP (op0, 0)) == LSHIFTRT)
+           {
+             rtx shift_op = XEXP (XEXP (op0, 0), 0);
+             rtx shift_count = XEXP (XEXP (op0, 0), 1);
+
+             if (GET_CODE (shift_op) == NOT
+                 || (GET_CODE (shift_op) == XOR
+                     && GET_CODE (XEXP (shift_op, 1)) == CONST_INT
+                     && GET_CODE (shift_count) == CONST_INT
+                     && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT
+                     && (INTVAL (XEXP (shift_op, 1))
+                         == (HOST_WIDE_INT) 1 << INTVAL (shift_count))))
+               {
+                 op0 = simplify_and_const_int
+                   (NULL_RTX, mode,
+                    gen_rtx_LSHIFTRT (mode, XEXP (shift_op, 0), shift_count),
+                    (HOST_WIDE_INT) 1);
+                 code = (code == NE ? EQ : NE);
+                 continue;
+               }
            }
          break;