[PATCH] fix useless unsharing of SLP tree
Richard Biener
rguenther@suse.de
Wed Sep 9 12:46:03 GMT 2020
This avoids unsharing the SLP tree when optimizing load permutations
for reductions but there is no actual permute taking place.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
2020-09-09 Richard Biener <rguenther@suse.de>
* 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 03b11058bd5..15d57890b6f 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -1905,11 +1905,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))
@@ -1917,6 +1920,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.26.2
More information about the Gcc-patches
mailing list