diff mbox series

Fix invalid assumption in vect_transform_stmt (PR 86871)

Message ID 87y3df1u7u.fsf@arm.com
State New
Headers show
Series Fix invalid assumption in vect_transform_stmt (PR 86871) | expand

Commit Message

Richard Sandiford Aug. 9, 2018, 2:37 p.m. UTC
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.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.

Comments

Richard Biener Aug. 9, 2018, 3:42 p.m. UTC | #1
On August 9, 2018 4:37:57 PM GMT+02:00, Richard Sandiford <richard.sandiford@arm.com> wrote:
>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?

OK. 

Richard. 

>Richard
>
>
>2018-08-09  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.
>
>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;
>+  }
>+ }
diff mbox series

Patch

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;
+  }
+ }