[llvm] [SCEV] Use context sensative reasoning in howFarToZero (PR #94525)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 5 12:32:16 PDT 2024
preames wrote:
Looking at this code, I think we can further improve the reasoning here in a couple of ways. Let me sketch out a few ideas here, so reviewers can see where this is going.
* I think we can avoid the need to statically know the sign bit. I think I have a SCEV expression which represents the select required for the Distance - though this is pending verification.
* I think we're being too conservative about applying no-self-wrap. (And by "we", I mean "I" as I wrote that code...) If we have any (not just sole) latch dominating exit which is controlled by an NW addrec, then we'd branch-on-poison on the iteration which violates the NW. As such, we can assume that that some other exit is taken first. We can consider the divide (ignoring wrap) as a bound for this exit by simply adding one to the result.
* Looking at other exit computation, it looks like I got the nw property wrong (too conservative) in a few cases, in slightly different ways. It looks like maybe I confused myself between the actual distance bound, and the repeats the same value variant - which aren't quite the same.
I'm probably going to post a patch for the first of those. Not sure I'm going to continue through with the later two, as they're a bit more involved.
https://github.com/llvm/llvm-project/pull/94525
More information about the llvm-commits
mailing list