Refine alingment peeling fix

Message ID 512s5s2s-35p7-n2s-n821-r88pp09rp17n@fhfr.qr
State Committed
Commit 09f032c22053f178c802d83a1dea49a0d47c7cc4
Headers
Series Refine alingment peeling fix |

Commit Message

Richard Biener Sept. 30, 2021, 11:08 a.m. UTC
  This refines the previous fix further by reverting to the original
code since the API is a bit of a mess.  It also fixes the vector type
used to query the misalignment - that was what triggered the original
bogus change.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

2021-09-30  Richard Biener  <rguenther@suse.de>

	* tree-vect-data-refs.c (vect_update_misalignment_for_peel):
	Restore and fix condition under which we apply npeel to
	the DRs misalignment value.
---
 gcc/tree-vect-data-refs.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
  

Patch

diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index bece58df3bf..07b5ba11f31 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -1262,10 +1262,11 @@  vect_update_misalignment_for_peel (dr_vec_info *dr_info,
     }
 
   unsigned HOST_WIDE_INT alignment;
-  tree vectype = STMT_VINFO_VECTYPE (dr_info->stmt);
   if (DR_TARGET_ALIGNMENT (dr_info).is_constant (&alignment)
-      && known_alignment_for_access_p (dr_info, vectype)
-      && npeel != 0)
+      && known_alignment_for_access_p (dr_info,
+				       STMT_VINFO_VECTYPE (dr_info->stmt))
+      && known_alignment_for_access_p (dr_peel_info,
+				       STMT_VINFO_VECTYPE (dr_peel_info->stmt)))
     {
       int misal = dr_info->misalignment;
       misal += npeel * TREE_INT_CST_LOW (DR_STEP (dr_info->dr));
@@ -1515,7 +1516,8 @@  vect_peeling_hash_get_most_frequent (_vect_peel_info **slot,
 
 /* Get the costs of peeling NPEEL iterations for LOOP_VINFO, checking
    data access costs for all data refs.  If UNKNOWN_MISALIGNMENT is true,
-   we assume DR0_INFO's misalignment will be zero after peeling.  */
+   npeel is computed at runtime but DR0_INFO's misalignment will be zero
+   after peeling.  */
 
 static void
 vect_get_peeling_costs_all_drs (loop_vec_info loop_vinfo,