[backport gcc-4.8/trunk r196458 ] gcc/ 2013-03-05 Richard Biener PR tree-optimization/56270 * tree-vect-slp.c (vect_schedule_slp): Clear vectorized stmts of loads after scheduling an SLP instance. gcc/testsuite/ 2013-03-05 Richard Biener PR tree-optimization/56270 * gcc.dg/vect/slp-38.c: New testcase. --- gcc-4.6.3/gcc/testsuite/gcc.dg/vect/slp-38.c.~1~ 2013-03-09 15:25:17.290504655 +0100 +++ gcc-4.6.3/gcc/testsuite/gcc.dg/vect/slp-38.c 2013-03-09 15:25:17.290504655 +0100 @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +typedef struct { + float l, h; +} tFPinterval; + +tFPinterval X[1024]; +tFPinterval Y[1024]; +tFPinterval Z[1024]; + +void Compute(void) +{ + int d; + for (d= 0; d < 1024; d++) + { + Y[d].l= X[d].l + X[d].h; + Y[d].h= Y[d].l; + Z[d].l= X[d].l; + Z[d].h= X[d].h; + } +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 1 "vect" { target { vect_float && vect_perm } } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ --- gcc-4.6.3/gcc/tree-vect-slp.c.~1~ 2010-12-23 17:25:52.000000000 +0100 +++ gcc-4.6.3/gcc/tree-vect-slp.c 2013-03-09 15:25:21.840485263 +0100 @@ -2532,7 +2532,8 @@ vect_schedule_slp (loop_vec_info loop_vi { VEC (slp_instance, heap) *slp_instances; slp_instance instance; - unsigned int i, vf; + slp_tree loads_node; + unsigned int i, j, vf; bool is_store = false; if (loop_vinfo) @@ -2551,6 +2552,14 @@ vect_schedule_slp (loop_vec_info loop_vi /* Schedule the tree of INSTANCE. */ is_store = vect_schedule_slp_instance (SLP_INSTANCE_TREE (instance), instance, vf); + + /* Clear STMT_VINFO_VEC_STMT of all loads. With shared loads + between SLP instances we fail to properly initialize the + vectorized SLP stmts and confuse different load permutations. */ + FOR_EACH_VEC_ELT (slp_tree, SLP_INSTANCE_LOADS (instance), j, loads_node) + STMT_VINFO_VEC_STMT + (vinfo_for_stmt (VEC_index (gimple, SLP_TREE_SCALAR_STMTS (loads_node), 0))) = NULL; + if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS) || vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS)) fprintf (vect_dump, "vectorizing stmts using SLP.");