[llvm] [SCCP] Extend `visitBinaryOperator` to overflowing binary ops (PR #84470)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 9 08:33:38 PST 2024
antoniofrighetto wrote:
> Another regression: https://github.com/dtcxzyw/llvm-opt-benchmark/pull/338/files#r1518193574
> Alive2: https://alive2.llvm.org/ce/z/pZwdiS
Note that this already happens to be handled when `isSignMask` adheres to the type bitwidth (https://alive2.llvm.org/ce/z/KL7JYt) here:
https://github.com/llvm/llvm-project/blob/2fe81edef6f0b35abffbbc59b649b30ea9c15a62/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp#L1768-L1772
If it makes sense, we can extend it to handle the following missing case:
```llvm
define i1 @src(i64 %a) {
entry:
%rem817 = urem i64 %a, 1000
%rem817.neg = sub nsw i64 0, %rem817
%1 = and i64 %rem817.neg, 2147483648
%cmp10.not = icmp eq i64 %1, 0
ret i1 %cmp10.not
}
```
However, I think this holds as long as `%rem817.neg` is bounded up to a certain constant, and the output for `computeKnownBits(And->getOperand(0), 0, And)` for this instance might be suboptimal (zeroes 0, zeroes 1)? Is there a better way to handle this?
https://github.com/llvm/llvm-project/pull/84470
More information about the llvm-commits
mailing list