From 58905f90434ba9a64abac56324131d67c53910ae Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 9 Sep 2020 13:58:45 +0200 Subject: [PATCH] fix useless unsharing of SLP tree This avoids unsharing the SLP tree when optimizing load permutations for reductions but there is no actual permute taking place. 2020-09-09 Richard Biener * tree-vect-slp.c (vect_attempt_slp_rearrange_stmts): Do nothing when the permutation doesn't permute. --- gcc/tree-vect-slp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index dcc80d55917..7860fe3f32b 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -1903,11 +1903,14 @@ vect_attempt_slp_rearrange_stmts (slp_instance slp_instn) } /* Check that the loads in the first sequence are different and there - are no gaps between them. */ + are no gaps between them and that there is an actual permutation. */ + bool any_permute = false; auto_sbitmap load_index (group_size); bitmap_clear (load_index); FOR_EACH_VEC_ELT (node->load_permutation, i, lidx) { + if (lidx != i) + any_permute = true; if (lidx >= group_size) return false; if (bitmap_bit_p (load_index, lidx)) @@ -1915,6 +1918,8 @@ vect_attempt_slp_rearrange_stmts (slp_instance slp_instn) bitmap_set_bit (load_index, lidx); } + if (!any_permute) + return false; for (i = 0; i < group_size; i++) if (!bitmap_bit_p (load_index, i)) return false; -- 2.30.2