Fix PR81362: Vector peeling
authorRobin Dapp <rdapp@linux.vnet.ibm.com>
Tue, 18 Jul 2017 09:23:35 +0000 (09:23 +0000)
committerAndreas Krebbel <krebbel@gcc.gnu.org>
Tue, 18 Jul 2017 09:23:35 +0000 (09:23 +0000)
npeel was erroneously overwritten by vect_peeling_hash_get_lowest_cost
although the corresponding dataref is not used afterwards.  It should
be safe to get rid of the npeel parameter since we use the returned
peeling_info's npeel anyway.  Also removed the body_cost_vec parameter
which is not used elsewhere.

gcc/ChangeLog:

2017-07-18  Robin Dapp  <rdapp@linux.vnet.ibm.com>

* tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Remove
body_cost_vec from _vect_peel_extended_info.
(vect_peeling_hash_get_lowest_cost): Do not set body_cost_vec.
(vect_peeling_hash_choose_best_peeling): Remove body_cost_vec and
npeel.

From-SVN: r250300

gcc/ChangeLog
gcc/tree-vect-data-refs.c

index 761dcbf4031bf7d94d24f5586de962e691b5aed4..5c2156f6a20b8767771d10481c87dd88b9336920 100644 (file)
@@ -1,3 +1,11 @@
+2017-07-18  Robin Dapp  <rdapp@linux.vnet.ibm.com>
+
+        * tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Remove
+       body_cost_vec from _vect_peel_extended_info.
+       (vect_peeling_hash_get_lowest_cost): Do not set body_cost_vec.
+        (vect_peeling_hash_choose_best_peeling): Remove body_cost_vec and
+       npeel.
+
 2017-07-18  Bin Cheng  <bin.cheng@arm.com>
 
        * config/arm/arm.c (emit_unlikely_jump): Remove unused var.
index 907f35e6703b7e3afa5a3ce1feb897d1c3f85feb..8b55d5948eaf7c866b1578b4e7ff7242cb8d720a 100644 (file)
@@ -1078,7 +1078,6 @@ typedef struct _vect_peel_extended_info
   struct _vect_peel_info peel_info;
   unsigned int inside_cost;
   unsigned int outside_cost;
-  stmt_vector_for_cost body_cost_vec;
 } *vect_peel_extended_info;
 
 
@@ -1226,6 +1225,8 @@ vect_peeling_hash_get_lowest_cost (_vect_peel_info **slot,
   vect_get_peeling_costs_all_drs (elem->dr, &inside_cost, &outside_cost,
                                  &body_cost_vec, elem->npeel, false);
 
+  body_cost_vec.release ();
+
   outside_cost += vect_get_known_peeling_cost
     (loop_vinfo, elem->npeel, &dummy,
      &LOOP_VINFO_SCALAR_ITERATION_COST (loop_vinfo),
@@ -1244,14 +1245,10 @@ vect_peeling_hash_get_lowest_cost (_vect_peel_info **slot,
     {
       min->inside_cost = inside_cost;
       min->outside_cost = outside_cost;
-      min->body_cost_vec.release ();
-      min->body_cost_vec = body_cost_vec;
       min->peel_info.dr = elem->dr;
       min->peel_info.npeel = elem->npeel;
       min->peel_info.count = elem->count;
     }
-  else
-    body_cost_vec.release ();
 
   return 1;
 }
@@ -1263,14 +1260,11 @@ vect_peeling_hash_get_lowest_cost (_vect_peel_info **slot,
 
 static struct _vect_peel_extended_info
 vect_peeling_hash_choose_best_peeling (hash_table<peel_info_hasher> *peeling_htab,
-                                      loop_vec_info loop_vinfo,
-                                       unsigned int *npeel,
-                                      stmt_vector_for_cost *body_cost_vec)
+                                      loop_vec_info loop_vinfo)
 {
    struct _vect_peel_extended_info res;
 
    res.peel_info.dr = NULL;
-   res.body_cost_vec = stmt_vector_for_cost ();
 
    if (!unlimited_cost_model (LOOP_VINFO_LOOP (loop_vinfo)))
      {
@@ -1288,8 +1282,6 @@ vect_peeling_hash_choose_best_peeling (hash_table<peel_info_hasher> *peeling_hta
        res.outside_cost = 0;
      }
 
-   *npeel = res.peel_info.npeel;
-   *body_cost_vec = res.body_cost_vec;
    return res;
 }
 
@@ -1454,7 +1446,6 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
   unsigned possible_npeel_number = 1;
   tree vectype;
   unsigned int nelements, mis, same_align_drs_max = 0;
-  stmt_vector_for_cost body_cost_vec = stmt_vector_for_cost ();
   hash_table<peel_info_hasher> peeling_htab (1);
 
   if (dump_enabled_p ())
@@ -1729,7 +1720,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
          unless aligned.  So we try to choose the best possible peeling from
         the hash table.  */
       peel_for_known_alignment = vect_peeling_hash_choose_best_peeling
-       (&peeling_htab, loop_vinfo, &npeel, &body_cost_vec);
+       (&peeling_htab, loop_vinfo);
     }
 
   /* Compare costs of peeling for known and unknown alignment. */
@@ -1755,7 +1746,8 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
     {
       /* Calculate the penalty for no peeling, i.e. leaving everything
         unaligned.
-        TODO: Adapt vect_get_peeling_costs_all_drs and use here.  */
+        TODO: Adapt vect_get_peeling_costs_all_drs and use here.
+        TODO: Use nopeel_outside_cost or get rid of it?  */
       unsigned nopeel_inside_cost = 0;
       unsigned nopeel_outside_cost = 0;
 
@@ -1837,10 +1829,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
           if (!stat)
             do_peeling = false;
           else
-           {
-             body_cost_vec.release ();
-             return stat;
-           }
+           return stat;
         }
 
       /* Cost model #1 - honor --param vect-max-peeling-for-alignment.  */
@@ -1916,19 +1905,16 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
               dump_printf_loc (MSG_NOTE, vect_location,
                                "Peeling for alignment will be applied.\n");
             }
+
          /* The inside-loop cost will be accounted for in vectorizable_load
             and vectorizable_store correctly with adjusted alignments.
             Drop the body_cst_vec on the floor here.  */
-         body_cost_vec.release ();
-
          stat = vect_verify_datarefs_alignment (loop_vinfo);
          gcc_assert (stat);
           return stat;
         }
     }
 
-  body_cost_vec.release ();
-
   /* (2) Versioning to force alignment.  */
 
   /* Try versioning if: