[RTL ifcvt] Allow simple register subregs in noce_convert_multiple_sets
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Wed, 15 Jun 2016 10:08:24 +0000 (10:08 +0000)
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>
Wed, 15 Jun 2016 10:08:24 +0000 (10:08 +0000)
* ifcvt.c (bb_ok_for_noce_multiple_sets): Allow simple lowpart
register subregs in SET_SRC.

* gcc.target/aarch64/ifcvt_multiple_sets_subreg_1.c: New test.

From-SVN: r237475

gcc/ChangeLog
gcc/ifcvt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/ifcvt_multiple_sets_subreg_1.c [new file with mode: 0644]

index ebc4d6e..6eb52a9 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-15  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       * ifcvt.c (bb_ok_for_noce_multiple_sets): Allow simple lowpart
+       register subregs in SET_SRC.
+
 2016-06-15  Richard Biener  <rguenther@suse.de>
 
        * tree-vect-stmts.c (vectorizable_store): Remove strided grouped
index 4a277db..fd29516 100644 (file)
@@ -3339,9 +3339,15 @@ bb_ok_for_noce_convert_multiple_sets (basic_block test_bb,
       rtx src = SET_SRC (set);
 
       /* We can possibly relax this, but for now only handle REG to REG
-        moves.  This avoids any issues that might come from introducing
-        loads/stores that might violate data-race-freedom guarantees.  */
-      if (!(REG_P (src) && REG_P (dest)))
+        (including subreg) moves.  This avoids any issues that might come
+        from introducing loads/stores that might violate data-race-freedom
+        guarantees.  */
+      if (!REG_P (dest))
+       return false;
+
+      if (!(REG_P (src)
+          || (GET_CODE (src) == SUBREG && REG_P (SUBREG_REG (src))
+              && subreg_lowpart_p (src))))
        return false;
 
       /* Destination must be appropriate for a conditional write.  */
index 679f022..e5100ab 100644 (file)
@@ -1,3 +1,7 @@
+2016-06-15  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       * gcc.target/aarch64/ifcvt_multiple_sets_subreg_1.c: New test.
+
 2016-06-15  Richard Biener  <rguenther@suse.de>
 
        * gcc.dg/vect/slp-45.c: New testcase.
diff --git a/gcc/testsuite/gcc.target/aarch64/ifcvt_multiple_sets_subreg_1.c b/gcc/testsuite/gcc.target/aarch64/ifcvt_multiple_sets_subreg_1.c
new file mode 100644 (file)
index 0000000..ac6ffdc
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-rtl-ce1" } */
+
+/* Check that the inner if is transformed into CSELs.  */
+
+int
+foo (int *x, int *z, int a)
+{
+  int b = 0;
+  int c = 0;
+  int d = 0;
+  int i;
+
+  for (i = 0; i < a; i++)
+    {
+      if (x[i] < c)
+       {
+         b = z[i];
+         if (c < b)
+           {
+             c = b;
+             d = i;
+           }
+       }
+    }
+
+  return c + d;
+}
+
+/* { dg-final { scan-rtl-dump "if-conversion succeeded through noce_convert_multiple_sets" "ce1" } } */