[llvm] [DA] Rewrite the formula in the Strong SIV test (PR #179665)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 22 05:31:33 PST 2026
kasuga-fj wrote:
> Can we express the condition proposed here like this instead?
>
> ```
> ConstantRange SrcRange = SE->getSignedRange(Src);
> ConstantRange DstRange = SE->getSignedRange(Dst);
> return SrcRange.intersectWith(DstRange).isEmptySet();
> ```
>
> This leaves the heavy lifting to SCEV and does not require nowrap flags -- not that I expect it to be useful, but we _can_ prove disjointness of wrapping ranges as well. It's also not specific to _strong_ SIV in particular. This seems like something we should just be checking upfront to discharge the "obvious" cases that BasicAA does not catch itself.
Wow, great, I've not realized that API. Yes, we can use this representation here, and it seems simpler and better than I proposed. I will update the patch accordingly. Thanks for the suggestion! This representation would also be applicable to other SIV tests, but at the moment I'll just update the Strong SIV test because maybe we need to remove some of the existing features for the other tests (e.g., `weakCrossingSIVtest`, where some additional checks are performed to handle special cases).
> For this test, I think you'll want to express it in the simplest way that works -- the precise way it is expressed is unlikely to affect practical analysis power.
This statement sounds perfectly reasonable to me. This test can probably only catch trivial cases, and it's still unclear to me whether this test is useful in the real-world use cases in the first place. Thus I had even started to think that it might be better to remove it if we couldn’t reach consensus. But anyway, we should definitely use the simplest way to express it, even if there exists a way that is in theoretically more precise but more complicated and unlikely to be practically useful.
https://github.com/llvm/llvm-project/pull/179665
More information about the llvm-commits
mailing list