https://bugs.gentoo.org/657060 https://gcc.gnu.org/PR86871 From c69949a7ec14a363128cd1445c7153e1ce051eb7 Mon Sep 17 00:00:00 2001 From: rsandifo Date: Tue, 14 Aug 2018 09:24:45 +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-14 Richard Sandiford gcc/ Backport from mainline 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. gcc/testsuite/ Backport from mainline 2018-08-09 Richard Sandiford PR tree-optimization/86871 * gcc.dg/vect/pr86871.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-8-branch@263528 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/gcc.dg/vect/pr86871.c | 15 +++++++++++++++ gcc/tree-vect-stmts.c | 2 +- 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr86871.c --- /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; + } + } --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -9602,7 +9602,7 @@ vect_transform_stmt (gimple *stmt, 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) { -- 2.20.1