https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88398
--- Comment #42 from Jiu Fu Guo <guojiufu at gcc dot gnu.org> --- (In reply to Jiu Fu Guo from comment #41) > (In reply to Wilco from comment #40) > > (In reply to Jiu Fu Guo from comment #39) > > > I’m thinking to draft a patch for this optimization. If any suggestions, > > > please point out, thanks. > > > > Which optimization to be precise? Besides unrolling I haven't seen a > > proposal for an optimization which is both safe and generally applicable. > > 1. For unroll, there are still branches in the loop. And then need careful > merge on those reading and comparison. Another thing about unroll would be > that, if we prefer to optimize this early in GIMPLE, we still not GIMPLE > unroll on it. > while (len != max) > { > if (p[len] != cur[len]) > break; ++len; > if (p[len] != cur[len]) > break; ++len; > if (p[len] != cur[len]) > break; ++len; > .... > } Besides we do not have GIMPLE unroll for this kind of code, this may also likely be transformed to vectorization.