The handling of outer-loop uses of inner-loop definitions assumed
that anything that wasn't a PHI would be a gassign, but as the test
shows, it's also possible for it to be a gcall.

Tested on aarch64-linux-gnu (with and without SVE), aarch64_be-elf and
x86_64-linux-gnu.  Applied as obvious to trunk, but OK for GCC 8 too?

Richard


2018-08-09  Richard Sandiford  <richard.sandif...@arm.com>

gcc/
        PR tree-optimization/86871
        * tree-vect-stmts.c (vect_transform_stmt): Use gimple_get_lhs
        instead of gimple_assign_lhs.

gcc/testsuite/
        PR tree-optimization/86871
        * gcc.dg/vect/pr86871.c: New test.

Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c       2018-08-01 16:29:32.291384402 +0100
+++ gcc/tree-vect-stmts.c       2018-08-09 15:34:54.968197176 +0100
@@ -9804,7 +9804,7 @@ vect_transform_stmt (stmt_vec_info stmt_
       if (gimple_code (stmt) == GIMPLE_PHI)
         scalar_dest = PHI_RESULT (stmt);
       else
-        scalar_dest = gimple_assign_lhs (stmt);
+        scalar_dest = gimple_get_lhs (stmt);
 
       FOR_EACH_IMM_USE_FAST (use_p, imm_iter, scalar_dest)
        if (!flow_bb_inside_loop_p (innerloop, gimple_bb (USE_STMT (use_p))))
Index: gcc/testsuite/gcc.dg/vect/pr86871.c
===================================================================
--- /dev/null   2018-07-26 10:26:13.137955424 +0100
+++ gcc/testsuite/gcc.dg/vect/pr86871.c 2018-08-09 15:34:54.964197212 +0100
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+extern int b[];
+extern int c[];
+void g(int f) {
+  for (; f; f++) {
+    int d = 0;
+    for (int e = -1; e <= 1; e++) {
+      int a = f + e;
+      if (a)
+        d = *(c + a);
+    }
+    *(b + f) = d;
+  }
+ }

Reply via email to