rtlanal.c (canonicalize_condition): Split out duplicated mode check.
authorRichard Sandiford <rdsandiford@googlemail.com>
Sat, 25 Jan 2014 20:03:16 +0000 (20:03 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Sat, 25 Jan 2014 20:03:16 +0000 (20:03 +0000)
gcc/
* rtlanal.c (canonicalize_condition): Split out duplicated mode check.
Handle XOR.

gcc/testsuite/
* gcc.dg/unroll_1.c: Add -fenable-rtl-loop2.

From-SVN: r207076

gcc/ChangeLog
gcc/rtlanal.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/unroll_1.c

index ea51b3e..563642e 100644 (file)
@@ -1,3 +1,8 @@
+2014-01-25  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * rtlanal.c (canonicalize_condition): Split out duplicated mode check.
+       Handle XOR.
+
 2014-01-25  Jakub Jelinek  <jakub@redhat.com>
 
        * print-rtl.c (in_call_function_usage): New var.
index aff8f53..7a9efec 100644 (file)
@@ -5051,23 +5051,24 @@ canonicalize_condition (rtx insn, rtx cond, int reverse, rtx *earliest,
 
             ??? This mode check should perhaps look more like the mode check
             in simplify_comparison in combine.  */
-
-         if ((GET_CODE (SET_SRC (set)) == COMPARE
-              || (((code == NE
-                    || (code == LT
-                        && val_signbit_known_set_p (inner_mode,
-                                                    STORE_FLAG_VALUE))
+         if (((GET_MODE_CLASS (mode) == MODE_CC)
+              != (GET_MODE_CLASS (inner_mode) == MODE_CC))
+             && mode != VOIDmode
+             && inner_mode != VOIDmode)
+           break;
+         if (GET_CODE (SET_SRC (set)) == COMPARE
+             || (((code == NE
+                   || (code == LT
+                       && val_signbit_known_set_p (inner_mode,
+                                                   STORE_FLAG_VALUE))
 #ifdef FLOAT_STORE_FLAG_VALUE
-                    || (code == LT
-                        && SCALAR_FLOAT_MODE_P (inner_mode)
-                        && (fsfv = FLOAT_STORE_FLAG_VALUE (inner_mode),
-                            REAL_VALUE_NEGATIVE (fsfv)))
+                   || (code == LT
+                       && SCALAR_FLOAT_MODE_P (inner_mode)
+                       && (fsfv = FLOAT_STORE_FLAG_VALUE (inner_mode),
+                           REAL_VALUE_NEGATIVE (fsfv)))
 #endif
-                    ))
-                  && COMPARISON_P (SET_SRC (set))))
-             && (((GET_MODE_CLASS (mode) == MODE_CC)
-                  == (GET_MODE_CLASS (inner_mode) == MODE_CC))
-                 || mode == VOIDmode || inner_mode == VOIDmode))
+                   ))
+                 && COMPARISON_P (SET_SRC (set))))
            x = SET_SRC (set);
          else if (((code == EQ
                     || (code == GE
@@ -5080,15 +5081,25 @@ canonicalize_condition (rtx insn, rtx cond, int reverse, rtx *earliest,
                             REAL_VALUE_NEGATIVE (fsfv)))
 #endif
                     ))
-                  && COMPARISON_P (SET_SRC (set))
-                  && (((GET_MODE_CLASS (mode) == MODE_CC)
-                       == (GET_MODE_CLASS (inner_mode) == MODE_CC))
-                      || mode == VOIDmode || inner_mode == VOIDmode))
-
+                  && COMPARISON_P (SET_SRC (set)))
            {
              reverse_code = 1;
              x = SET_SRC (set);
            }
+         else if ((code == EQ || code == NE)
+                  && GET_CODE (SET_SRC (set)) == XOR)
+           /* Handle sequences like:
+
+              (set op0 (xor X Y))
+              ...(eq|ne op0 (const_int 0))...
+
+              in which case:
+
+              (eq op0 (const_int 0)) reduces to (eq X Y)
+              (ne op0 (const_int 0)) reduces to (ne X Y)
+
+              This is the form used by MIPS16, for example.  */
+           x = SET_SRC (set);
          else
            break;
        }
index 899211b..9579219 100644 (file)
@@ -1,3 +1,7 @@
+2014-01-25  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * gcc.dg/unroll_1.c: Add -fenable-rtl-loop2.
+
 2014-01-25  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        * gcc.dg/vect/vect-nop-move.c (main): Check for vect runtime.
index 378f819..b1d3e7c 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-rtl-loop2_unroll=stderr -fno-peel-loops -fno-tree-vrp -fdisable-tree-cunroll -fdisable-tree-cunrolli -fenable-rtl-loop2_unroll" } */
+/* { dg-options "-O2 -fdump-rtl-loop2_unroll=stderr -fno-peel-loops -fno-tree-vrp -fdisable-tree-cunroll -fdisable-tree-cunrolli -fenable-rtl-loop2 -fenable-rtl-loop2_unroll" } */
 
 unsigned a[100], b[100];
 inline void bar()