[llvm] [InstCombine] Handle `ICMP_EQ` when flooring by constant two (PR #73706)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 28 16:30:28 PST 2023
================
@@ -1234,14 +1234,21 @@ static Instruction *foldAddToAshr(BinaryOperator &Add) {
return nullptr;
// Rounding is done by adding -1 if the dividend (X) is negative and has any
- // low bits set. The canonical pattern for that is an "ugt" compare with SMIN:
- // sext (icmp ugt (X & (DivC - 1)), SMIN)
- const APInt *MaskC;
+ // low bits set. It recognizes two canonical patterns:
+ // 1. For an 'ugt' cmp with the signed minimum value (SMIN), the
+ // pattern is: sext (icmp ugt (X & (DivC - 1)), SMIN).
+ // 2. For an 'eq' cmp, the pattern is: sext (icmp eq (SMIN + 1), SMIN + 1).
----------------
dtcxzyw wrote:
```suggestion
// 2. For an 'eq' cmp, the pattern is: sext (icmp eq X & (SMIN + 1), SMIN + 1).
```
https://github.com/llvm/llvm-project/pull/73706
More information about the llvm-commits
mailing list