When the unrolling decision comes late and would have prevented
eliding a SLP load permutation we can end up generating aligned
loads when the load is in fact unaligned.  Most of the time
alignment analysis figures out the load is in fact unaligned
but that cannot be relied upon.

The following removes the SLP load permutation eliding based on
the still premature vectorization factor.

This is only necessary on branches since on trunk this optimization
is delayed upon a point where the vectorization factor is final.

Bootstrap & regtest running on x86_64-unknown-linux-gnu.

2020-09-14  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/97043
        * tree-vect-slp.c (vect_analyze_slp_instance): Do not
        elide a load permutation if the current vectorization
        factor is one.
---
 gcc/tree-vect-slp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index f6331eeea86..3fdf56f9335 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -2309,9 +2309,8 @@ vect_analyze_slp_instance (vec_info *vinfo,
                  /* The load requires permutation when unrolling exposes
                     a gap either because the group is larger than the SLP
                     group-size or because there is a gap between the groups.  
*/
-                 && (known_eq (unrolling_factor, 1U)
-                     || (group_size == DR_GROUP_SIZE (first_stmt_info)
-                         && DR_GROUP_GAP (first_stmt_info) == 0)))
+                 && group_size == DR_GROUP_SIZE (first_stmt_info)
+                 && DR_GROUP_GAP (first_stmt_info) == 0)
                {
                  SLP_TREE_LOAD_PERMUTATION (load_node).release ();
                  continue;
-- 
2.26.2

Reply via email to