From 565bc8fb6ed14656da63057a5c9c2c3e88aa05fc Mon Sep 17 00:00:00 2001 From: rguenth Date: Wed, 16 Dec 2015 13:45:40 +0000 Subject: [PATCH] 2015-12-16 Richard Biener PR tree-optimization/68861 * tree-vect-slp.c (vect_build_slp_tree): Properly handle duplicate stmts when applying swapping to stmts. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231689 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/tree-vect-slp.c | 24 +++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 78dc4e3b21dd..c74d25a5478e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-12-16 Richard Biener + + PR tree-optimization/68861 + * tree-vect-slp.c (vect_build_slp_tree): Properly handle + duplicate stmts when applying swapping to stmts. + 2015-12-16 Kirill Yukhin * config/i386/i386-c.c (ix86_target_macros_internal): Remove diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index f57c859cd4ad..6955e15775e6 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -1049,11 +1049,29 @@ vect_build_slp_tree (vec_info *vinfo, if we end up building the operand from scalars as we'll continue to process swapped operand two. */ for (j = 0; j < group_size; ++j) - if (!matches[j]) + { + gimple *stmt = SLP_TREE_SCALAR_STMTS (*node)[j]; + gimple_set_plf (stmt, GF_PLF_1, false); + } + for (j = 0; j < group_size; ++j) + { + gimple *stmt = SLP_TREE_SCALAR_STMTS (*node)[j]; + if (!matches[j]) + { + /* Avoid swapping operands twice. */ + if (gimple_plf (stmt, GF_PLF_1)) + continue; + swap_ssa_operands (stmt, gimple_assign_rhs1_ptr (stmt), + gimple_assign_rhs2_ptr (stmt)); + gimple_set_plf (stmt, GF_PLF_1, true); + } + } + /* Verify we swap all duplicates or none. */ + if (flag_checking) + for (j = 0; j < group_size; ++j) { gimple *stmt = SLP_TREE_SCALAR_STMTS (*node)[j]; - swap_ssa_operands (stmt, gimple_assign_rhs1_ptr (stmt), - gimple_assign_rhs2_ptr (stmt)); + gcc_assert (gimple_plf (stmt, GF_PLF_1) == ! matches[j]); } /* If we have all children of child built up from scalars then -- 2.47.2