https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119399
--- Comment #5 from Richard Sandiford <rsandifo at gcc dot gnu.org> --- (In reply to rguent...@suse.de from comment #4) > >, so for a 4-element > > vector, the only problem cases are p==q+4, p==q+8 and p==q+12. That's > > equivalent to testing whether the unsigned value p-(q+4) <= 8. > > So the reasoning is that for p == q + 12 iff q + 12 wraps then > it has to be outside of the object, thus n is low enough that > we don't reach that point? Yeah. > w/o alignment knowledge problematic cases would include p == q + 1 > to p == q + 15, but that would still be no problem I think, the > same wrapping argument can be used to simplify the > p == q + 15 compare to p - (q + 4) <= 11? What was the reason > to not do p - q <= 15 (or 12)? p - q <= 15 would include p == q, but we should use the vector loop for that. FWIW, the current condition for unaligned pointers is: _46 = q_11(D) + 4; _15 = p_12(D) - _46; _54 = (sizetype) _15; _32 = _54 + 3; if (_32 > 14) goto <bb 5>; [89.44%] else goto <bb 11>; [10.56%] [https://godbolt.org/z/6ra5o4Wj9] but the forthcoming patch will make it: _46 = (sizetype) p_12(D); _15 = (sizetype) q_11(D); _34 = _46 + 18446744073709551615; _35 = _34 - _15; if (_35 > 14) goto <bb 5>; [89.44%] else goto <bb 11>; [10.56%]