On Wed, Jan 15, 2014 at 02:06:24PM +0100, Richard Biener wrote: > > This should fix PR59822, us creating in valid SSA form when > hoisting a[i_2] out of a loop where i_2 is defined inside the loop. > > Bootstrap / regtest running on x86_64-unknown-linux-gnu.
Unfortunately with my patch on top of that (with obvious adjustment that it applies against the changed vectorizable_load code) still fails on lots of testcases, e.g. /usr/src/gcc/obj877/gcc/xgcc -B/usr/src/gcc/obj877/gcc/ /usr/src/gcc/gcc/testsuite/gcc.dg/vect/pr31343.c -fno-diagnostics-show-caret -fdiagnostics-color=never -msse2 -ftree-vectorize -fno-vect-cost-model -fno-common -O2 -fdump-tree-vect-details -S -o pr31343.s /usr/src/gcc/gcc/testsuite/gcc.dg/vect/pr31343.c: In function 'main1': /usr/src/gcc/gcc/testsuite/gcc.dg/vect/pr31343.c:12:1: internal compiler error: in op_iter_init, at ssa-iterators.h:602 0x89aa2fe op_iter_init ../../gcc/ssa-iterators.h:600 0x81232a9 op_iter_init ../../gcc/ssa-iterators.h:600 0x89bd936 op_iter_init_tree ../../gcc/ssa-iterators.h:662 0x89bd936 hoist_defs_of_uses ../../gcc/tree-vect-stmts.c:5507 0x89bd936 vectorizable_load ../../gcc/tree-vect-stmts.c:6442 I think that has to do with nested loop vectorization and inv_p being true in the inner loop for: # j_54 = PHI <j_45(5), 0(4)> ... _40 = ub[j_54]; and thus def_stmt is GIMPLE_PHI and FOR_EACH_SSA_TREE_OPERAND isn't allowed on those. Perhaps we want to avoid doing the hoisting for nested loop vectorization? And perhaps hoist_defs_of_uses should return false if gimple_code (def_stmt) == GIMPLE_PHI? Jakub