Fix invalid assumption in vect_transform_stmt (PR 86871)
authorRichard Sandiford <richard.sandiford@arm.com>
Thu, 9 Aug 2018 14:37:24 +0000 (14:37 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Thu, 9 Aug 2018 14:37:24 +0000 (14:37 +0000)
The handling of outer-loop uses of inner-loop definitions assumed
that anything that wasn't a PHI would be a gassign.  It's also
possible for it to be a gcall.

2018-08-08  Richard Sandiford  <richard.sandiford@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.

From-SVN: r263447

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr86871.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

index 9d5a23fc06fefe07df39974aba83b24e4e22104f..3e5f849e252a5edc6f997c601e4db78a8c90e695 100644 (file)
@@ -1,3 +1,9 @@
+2018-08-09  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR tree-optimization/86871
+       * tree-vect-stmts.c (vect_transform_stmt): Use gimple_get_lhs
+       instead of gimple_assign_lhs.
+
 2018-08-09  Richard Earnshaw  <rearnsha@arm.com>
 
        PR target/86887
index ac615177b280dd1fcfb4ed717e245c7057e55285..1edcf1eb7f791e9cf70456b65390e65dde2ec9a8 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-09  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR tree-optimization/86871
+       * gcc.dg/vect/pr86871.c: New test.
+
 2018-08-09  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * g++.old-deja/g++.mike/p784.C: Add -fpermissive.
diff --git a/gcc/testsuite/gcc.dg/vect/pr86871.c b/gcc/testsuite/gcc.dg/vect/pr86871.c
new file mode 100644 (file)
index 0000000..a181681
--- /dev/null
@@ -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;
+  }
+ }
index cfc8388384411a50a80a0456b3cc16aebe413ae0..89d516c4f4e737e8824c9dceef94fc22cba5aac7 100644 (file)
@@ -9804,7 +9804,7 @@ vect_transform_stmt (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
       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))))