This teaches SCEV to calculate range of a PHI as a union of its underlying values ranges.
Currently we do it by uniting ranges of its inputs, but there are cases where two or more PHIs
are cycled so such approach would give the full range.
This uses PhiValues analysis to get underlying values for PHIs and then unite their ranges.
Details
- Reviewers
mkazantsev nikic reames fhahn
Diff Detail
Event Timeline
Need to carefully think how to invalidate it correctly. I guess you need updates in forgetValue and maybe somewhere else.
llvm/lib/CodeGen/SafeStack.cpp | ||
---|---|---|
920 | Can we reuse cached result from analysis? |
@nikic this is not a final solution, but could you please evaluate CT impact of this one? Just for reference.
Unfortunately there is a crash when building test-suite: http://llvm-compile-time-tracker.com/show_error.php?commit=d1ebd749bf430527616aab33a7340f9fd2736228
Note that to make this change viable, every pass that preserves SCEV must also preserve PhiValues -- I doubt this is worth the effort or complexity.
Likely this is due to missing invalidation. @dmakogon pls fix the known issue and run more extensive fuzz testing to find what else is missing.
@nikic it shouldn't be a problem. If I'm reading this correctly, PhiValues makes computation lazily by request and supports by-value invalidation. If we have preserved SCEV => we have forgotten all values in SCEV that need to be forgotten => we have also invalidated them in PhiValues. This automatically gives what we want, no?
Marking as changes requested for now due to known issues.
I'm not sure this is true, because PhiValues will also contain phis that are outside loops, and those may not get invalidated by SCEVs invalidation mechanisms, right?
Can we reuse cached result from analysis?