diff mbox

Improve peeling heuristic in the vectorizer

Message ID BANLkTimUp8Rk3DFCHmqUikr=GSoG2y9jww@mail.gmail.com
State Accepted
Headers show

Commit Message

Ira Rosen June 12, 2011, 6:40 a.m. UTC
Hi,

gcc.dg/vect/vect-72.c is not expected to use loop peeling for
alignment, but it does on ARM with double-word vectors. The loop
contains two data-refs of type char: one is aligned and the other is
misaligned by 1. When the cost model is disabled the peeling heuristic
chooses to peel a number of scalar iterations that aligns the highest
number of data-refs in the loop. When there are two (with different
alignment), the decision is arbitrary, which causes the vectorizer to
peel 7 iterations in vect-72.c, while not peeling at all is an
obviously better option (at least since the cost model is disabled).
This patch takes into account the required number of iterations to
peel.

Bootstrapped and tested on powerpc64-suse-linux, and tested the
vectorizer testsuite on arm-linux-gnueabi.
Committed.

Ira

ChangeLog:

      * tree-vect-data-refs.c (vect_peeling_hash_get_most_frequent):
      Take number of iterations to peel into account for equally frequent
      misalignment values.
diff mbox

Patch

Index: tree-vect-data-refs.c
===================================================================
--- tree-vect-data-refs.c       (revision 174964)
+++ tree-vect-data-refs.c       (working copy)
@@ -1248,7 +1248,9 @@  vect_peeling_hash_get_most_frequent (void **slot,
   vect_peel_info elem = (vect_peel_info) *slot;
   vect_peel_extended_info max = (vect_peel_extended_info) data;

-  if (elem->count > max->peel_info.count)
+  if (elem->count > max->peel_info.count
+      || (elem->count == max->peel_info.count
+          && max->peel_info.npeel > elem->npeel))
     {
       max->peel_info.npeel = elem->npeel;
       max->peel_info.count = elem->count;