[Bug tree-optimization/88398] vectorization failure for a small loop to do byte comparison

ktkachov at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Dec 7 09:12:00 GMT 2018


ktkachov at gcc dot gnu.org changed:

           What    |Removed                     |Added
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-12-07
                 CC|                            |ktkachov at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #6 from ktkachov at gcc dot gnu.org ---
(In reply to Richard Biener from comment #5)
> Well, the main issue is that the loop has two exits which is something the
> vectorizer doesn't support (with a hard check).  Jakub explains why that is
> so.
> You could change the loop to sth like
>   unsigned char *p = cur + pos;
>   int len = 0;
>   int diff_pos = __INT_MAX__;
>   while (++len != max)
>     if (p[len] != cur[len])
>       diff_pos = len < diff_pos ? len : diff_pos;
>   return cur[diff_pos];
> which then runs into a limitation recently reported (two dependent
> reductions not recognized).

Could GCC generate this version and select it at runtime if max is sufficiently

More information about the Gcc-bugs mailing list