Fix invalid assumption in vect_transform_stmt (PR 86871)

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
This commit is contained in:
Richard Sandiford 2018-08-09 14:37:24 +00:00 committed by Richard Sandiford
parent 16621f0de3
commit 4beb66421f
4 changed files with 27 additions and 1 deletions

View 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

View 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.

View File

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

View 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))))