From 5e6667b25b02077d6c0a85dc7a60d3eafb005404 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 10 Jan 2014 13:07:42 +0000 Subject: [PATCH] re PR tree-optimization/59374 (-ftree-slp-vectorize breaks unique_ptr's move constructor) 2014-01-10 Richard Biener PR tree-optimization/59374 * tree-vect-slp.c (vect_slp_analyze_bb_1): Move dependence checking after SLP discovery. Mark stmts not participating in any SLP instance properly. * gcc.dg/torture/pr59374-3.c: New testcase. From-SVN: r206523 --- gcc/ChangeLog | 7 +++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.dg/torture/pr59374-3.c | 21 +++++++++++++++ gcc/tree-vect-slp.c | 34 ++++++++++++++++-------- 4 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr59374-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b6f808903ff..7b5229136a7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-01-10 Richard Biener + + PR tree-optimization/59374 + * tree-vect-slp.c (vect_slp_analyze_bb_1): Move dependence + checking after SLP discovery. Mark stmts not participating + in any SLP instance properly. + 2014-01-10 Kyrylo Tkachov * config/arm/arm.c (arm_new_rtx_costs): Use destination mode diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2e3b11d9e6a..a5738130f44 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-01-10 Richard Biener + + PR tree-optimization/59374 + * gcc.dg/torture/pr59374-3.c: New testcase. + 2014-01-10 Kyrylo Tkachov * lib/target-supports.exp diff --git a/gcc/testsuite/gcc.dg/torture/pr59374-3.c b/gcc/testsuite/gcc.dg/torture/pr59374-3.c new file mode 100644 index 00000000000..ab0014d8f13 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr59374-3.c @@ -0,0 +1,21 @@ +extern void abort (void); + +static struct X { void *a; void *b; } a, b; + +void __attribute__((noinline)) foo (void) +{ + void *tem = a.b; + a.b = (void *)0; + b.b = tem; + b.a = a.a; + a.a = tem; +} + +int main() +{ + a.b = &a; + foo (); + if (b.b != &a) + abort (); + return 0; +} diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 2b075dfea96..372d7db3e70 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -2110,17 +2110,6 @@ vect_slp_analyze_bb_1 (basic_block bb) vect_pattern_recog (NULL, bb_vinfo); - if (!vect_slp_analyze_data_ref_dependences (bb_vinfo)) - { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "not vectorized: unhandled data dependence " - "in basic block.\n"); - - destroy_bb_vec_info (bb_vinfo); - return NULL; - } - if (!vect_analyze_data_refs_alignment (NULL, bb_vinfo)) { if (dump_enabled_p ()) @@ -2155,6 +2144,29 @@ vect_slp_analyze_bb_1 (basic_block bb) vect_mark_slp_stmts_relevant (SLP_INSTANCE_TREE (instance)); } + /* Mark all the statements that we do not want to vectorize. */ + for (gimple_stmt_iterator gsi = gsi_start_bb (BB_VINFO_BB (bb_vinfo)); + !gsi_end_p (gsi); gsi_next (&gsi)) + { + stmt_vec_info vinfo = vinfo_for_stmt (gsi_stmt (gsi)); + if (STMT_SLP_TYPE (vinfo) != pure_slp) + STMT_VINFO_VECTORIZABLE (vinfo) = false; + } + + /* Analyze dependences. At this point all stmts not participating in + vectorization have to be marked. Dependence analysis assumes + that we either vectorize all SLP instances or none at all. */ + if (!vect_slp_analyze_data_ref_dependences (bb_vinfo)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "not vectorized: unhandled data dependence " + "in basic block.\n"); + + destroy_bb_vec_info (bb_vinfo); + return NULL; + } + if (!vect_verify_datarefs_alignment (NULL, bb_vinfo)) { if (dump_enabled_p ())