re PR tree-optimization/71818 (ICE in as_a, at is-a.h:192 w/ -O2 -ftree-vectorize)
authorAlan Hayward <alan.hayward@arm.com>
Mon, 1 Aug 2016 14:33:23 +0000 (14:33 +0000)
committerAlan Hayward <alahay01@gcc.gnu.org>
Mon, 1 Aug 2016 14:33:23 +0000 (14:33 +0000)
2016-08-01  Alan Hayward  <alan.hayward@arm.com>

gcc/
PR tree-optimization/71818
* tree-vect-loop-manip.c (vect_can_advance_ivs_p): Don't advance IVs
with non invariant evolutions

testsuite/
PR tree-optimization/71818
* gcc.dg/vect/pr71818.c: New

From-SVN: r238955

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr71818.c [new file with mode: 0644]
gcc/tree-vect-loop-manip.c

index d5643ceaae36dcf96585de4b5d3ef394433ccfdd..e97f2ccc630c6913232ebfaa3128fbd44f001b10 100644 (file)
@@ -1,3 +1,9 @@
+2015-08-01  Alan Hayward <alan.hayward@arm.com>
+
+       PR tree-optimization/71818
+       * tree-vect-loop-manip.c (vect_can_advance_ivs_p): Don't advance IVs
+       with non invariant evolutions
+
 2016-08-01  Georg-Johann Lay  <avr@gjlay.de>
 
        PR target/72767
index 2e015d927da27d2f4dd7fe5d96c8a446c66604b5..8b65b3ee01fd35db2d33e7b11ccc7c56ce05d9bd 100644 (file)
@@ -1,3 +1,8 @@
+2015-08-01  Alan Hayward <alan.hayward@arm.com>
+
+       PR tree-optimization/71818
+       * gcc.dg/vect/pr71818.c: New
+
 2016-08-01  Martin Liska  <mliska@suse.cz>
 
        PR tree-optimization/71857
diff --git a/gcc/testsuite/gcc.dg/vect/pr71818.c b/gcc/testsuite/gcc.dg/vect/pr71818.c
new file mode 100644 (file)
index 0000000..2946551
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+char a;
+short b;
+int c, d;
+void fn1() {
+  char e = 75, g;
+  unsigned char *f = &e;
+  a = 21;
+  for (; a <= 48; a++) {
+    for (; e <= 6;)
+      ;
+    g -= e -= b || g <= c;
+  }
+  d = *f;
+}
index c1381b366cf969e08dc84ebcec4f7934b1c90cfe..ec863b4af1ffbacf98c99158fd2c0901e42bcb0d 100644 (file)
@@ -40,6 +40,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cfgloop.h"
 #include "tree-scalar-evolution.h"
 #include "tree-vectorizer.h"
+#include "tree-ssa-loop-ivopts.h"
 
 /*************************************************************************
   Simple Loop Peeling Utilities
@@ -1591,11 +1592,27 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
          return false;
         }
 
+      /* FORNOW: We do not transform initial conditions of IVs
+        which evolution functions are not invariants in the loop.  */
+
+      if (!expr_invariant_in_loop_p (loop, evolution_part))
+       {
+         if (dump_enabled_p ())
+           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                            "evolution not invariant in loop.\n");
+         return false;
+       }
+
       /* FORNOW: We do not transform initial conditions of IVs
         which evolution functions are a polynomial of degree >= 2.  */
 
       if (tree_is_chrec (evolution_part))
-       return false;
+       {
+         if (dump_enabled_p ())
+           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                            "evolution is chrec.\n");
+         return false;
+       }
     }
 
   return true;