[PATCH] D74484: [AggressiveInstCombine] Add support for ICmp instr that feeds a select intsr's condition operand.

Ayman Musa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 08:06:57 PDT 2020


aymanmus added inline comments.


================
Comment at: llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp:109
+  // If one of them is a constant, return true.
+  if (HasConst)
+    return true;
----------------
nikic wrote:
> Is it really sufficient that just one of them is a constant? Say we have `(zext i16 %x to i32) ult -1`, which is always true, converting it to `i16 %x ult -1` would no longer be always true.
Making sure the const operand is valid for shrinking is done before we reach this point (line 82):


```
if (Ty && Ty->getScalarSizeInBits() < getConstMinBitWidth(IsSigned, C))
        return false;
```

If we reach this point, then the constant is valid.
Added a test case that exactly checks the scenario you offered.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74484/new/

https://reviews.llvm.org/D74484





More information about the llvm-commits mailing list