llvm-project
624b8953 - [SCEV] Derive x >=s 0 from x <u y and y <=u 2^(n-1) (#231631)

Commit
27 days ago
[SCEV] Derive x >=s 0 from x <u y and y <=u 2^(n-1) (#231631) Let `n` be the bit width of `x` and `y`. If `x <u y` and `y <=u 2^(n-1)`, then `x <u 2^(n-1)`, so `x >=s 0`. Here `y <=u 2^(n-1)` means `y >=s 0` or `y == INT_MIN`. In the same way, if `x <=u y` and `y <u 2^(n-1)`, then `x >=s 0`. This lets a guard like `x <u len` prove `x >=s 0` when `len` is non-negative. First, we prove the `x >=s 0` fact, and then try to imply the fact that SCEV was asked about from this fact. This is to allow implication of weaker bounds, e.g. `x >=s c, c <= 0`. `y` is checked via ranges only, to keep compile time low. Alive2 check - [link](https://alive2.llvm.org/ce/z/RScq69). --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Author
Parents
Loading