https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88398
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 large?