From 4beb66421fe0e19d3310c75af3502018119423c6 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Thu, 9 Aug 2018 14:37:24 +0000 Subject: [PATCH] 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 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 | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/vect/pr86871.c | 15 +++++++++++++++ gcc/tree-vect-stmts.c | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr86871.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9d5a23fc06f..3e5f849e252 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-08-09 Richard Sandiford + + 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 PR target/86887 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ac615177b28..1edcf1eb7f7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-08-09 Richard Sandiford + + PR tree-optimization/86871 + * gcc.dg/vect/pr86871.c: New test. + 2018-08-09 Paolo Carlini * 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 index 00000000000..a1816819e48 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr86871.c @@ -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 --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index cfc83883844..89d516c4f4e 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -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)))) -- 2.30.2