[gcc r11-3074] fix useless unsharing of SLP tree

Richard Biener rguenth@gcc.gnu.org
Wed Sep 9 12:46:25 GMT 2020


https://gcc.gnu.org/g:58905f90434ba9a64abac56324131d67c53910ae

commit r11-3074-g58905f90434ba9a64abac56324131d67c53910ae
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Sep 9 13:58:45 2020 +0200

    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  <rguenther@suse.de>
    
            * tree-vect-slp.c (vect_attempt_slp_rearrange_stmts): Do
            nothing when the permutation doesn't permute.

Diff:
---
 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;


More information about the Gcc-cvs mailing list