[llvm] [LVI] Generalize mask not equal conditions handling (PR #92946)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 4 05:51:20 PDT 2024


nikic wrote:

> > To give an example, let's say C=0 (ignoring the existing special case). Then the range for EQ will be `[0, ~Mask]`. The range for NE you would compute is `[~Mask + 1, MAX]`, which is (very) incorrect.
> 
> Revisited this better, yet I'm still unsure. If C=0, the range for EQ is indeed `[0, ~Mask]`, so the inverse is `[~Mask + 1, MAX]`, that is precisely the one you obtain in the current existing case, which should be correct. Could you please show another example where inverse leads to improper result? AFAICT we should be wrong only when `(Val & Mask) == C` is unsat, in which case we ensure to be conservative.

No, the existing case returns something different. Let's say you have Mask = 0b0011. Then valid values would be 0b0001, 0b0010 and 0b0011 (but not 0b0000). The existing code returns `[0b0001, MAX]`, not `[0b1101, MAX]`.

https://github.com/llvm/llvm-project/pull/92946


More information about the llvm-commits mailing list