https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112706
--- Comment #3 from Jan Hubicka <hubicka at ucw dot cz> --- Thanks, new pattern looks like noticeable improvement :) Base+offset is effective for alias analysis and I suppose it happens reasonably enough for compares as well. > _76 = _71 + 4; > # .MEM_154 = VDEF <.MEM_153> > x_3(D)->D.25942._M_implD.25172.D.25249._M_finishD.25175 = _76; > # .MEM_7 = VDEF <.MEM_154> > D.26033 = 0; > # .MEM_157 = VDEF <.MEM_7> > *_76 = 0; > # PT = nonlocal escaped > _82 = _71 + 8; > # .MEM_158 = VDEF <.MEM_157> > x_3(D)->D.25942._M_implD.25172.D.25249._M_finishD.25175 = _82; > # .MEM_8 = VDEF <.MEM_158> > D.26033 ={v} {CLOBBER(eol)}; > # .MEM_9 = VDEF <.MEM_8> > D.26034 = 0; > if (_66 != _82) > ``` > After pre (note the first comparison is gone but not the second one and maybe > a > 3rd). So this patch helps but it looks like a PRE/VN improvement is still > needed to fix the others. I think it is missing predication in VN. At each execution of CCP or VN we work out one conditional to be true, but we stil account both paths for the value number of the pointer used in next compare. If vector used base+size pair instead of base+endptr VRP would help here, but we can't vrp finish-start range...