https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104986
--- Comment #5 from Andrew Macleod <amacleod at redhat dot com> ---
(In reply to Richard Biener from comment #3)
> This is peeling leaving us with unreachable code we warn on and somehow
> while figuring prephitmp_30 + -6 is -1 we don't figure nb_58 is zero on
> the path to bb9.
>
> I think I've seen this backward-forward dependency issue with ranger before
> in another missed optimization PR.
(In reply to Richard Biener from comment #3)
> This is peeling leaving us with unreachable code we warn on and somehow
> while figuring prephitmp_30 + -6 is -1 we don't figure nb_58 is zero on
> the path to bb9.
>
> I think I've seen this backward-forward dependency issue with ranger before
> in another missed optimization PR.
DOM3 is the pass which converted prephitmp_30 + -6 to -1, and left nb_58 as is.
Ranger appears to see it just fine. Looking at VRP2,
Folding statement: nb_68 = prephitmp_30 + -5;
Queued stmt for removal. Folds to: 0
<...>
Folding statement: if (nb_68 != 0)
gimple_simplified to if (0 != 0)
Folded into: if (0 != 0)
strlen runs just before vrp2, and if I put a VRP pass immediately before
strlen1, then the warning goes away.
Looking at the strlen1 output, it only ever asks ranger about 6 names:
334 range_of_expr(_36) at stmt _52 = iftmp.1_17 + _36;
TRUE : (334) range_of_expr (_36) sizetype [3, 5]
maybe_invalidate called for *_52 = _60;
maybe_invalidate returns 1
342 range_of_expr(_69) at stmt _71 = iftmp.1_7 + _69;
TRUE : (342) range_of_expr (_69) sizetype [3, 5]
maybe_invalidate called for *_71 = _72;
maybe_invalidate returns 1
348 range_of_expr(_6) at stmt _31 = iftmp.1_76 + _6;
TRUE : (348) range_of_expr (_6) sizetype [2, 4]
maybe_invalidate called for *_31 = _32;
maybe_invalidate returns 1
367 range_of_expr(_37) at stmt _39 = iftmp.1_76 + _37;
TRUE : (367) range_of_expr (_37) sizetype [1, 3]
maybe_invalidate called for *_39 = _40;
statement may clobber object _31 0 bytes in size
maybe_invalidate returns 1
375 range_of_expr(_45) at stmt _47 = iftmp.1_76 + _45;
TRUE : (375) range_of_expr (_45) sizetype [0, 2]
maybe_invalidate called for *_47 = _48;
statement may clobber object _39 0 bytes in size
maybe_invalidate returns 1
383 range_of_expr(_53) at stmt _55 = iftmp.1_76 + _53;
TRUE : (383) range_of_expr (_53) sizetype [1, 1]
Is there a reason it runs before vrp2?