[PATCH] D108049: [InstCombine] Extend canonicalizeClampLike to handle truncated inputs

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 28 06:20:48 PDT 2021


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:1425
+  // are free to extend due to being constants.
+  if (X->getType() != Sel0.getType() &&
+      (!match(ReplacementLow, m_ImmConstant()) ||
----------------
It would be clearer to follow the optional casting logic if we consolidate it one block with something like this:

```
  if (X->getType() != Sel0.getType()) {
    Constant *LowC, *HighC;
    if (!match(ReplacementLow, m_ImmConstant(LowC)) ||
        !match(ReplacementHigh, m_ImmConstant(HighC)))
      return nullptr;
    ReplacementLow = ConstantExpr::getSExt(LowC, X->getType());
    ReplacementHigh = ConstantExpr::getSExt(HighC, X->getType());
  }

```

...and then get rid of the CreateSext diffs below here?


================
Comment at: llvm/test/Transforms/InstCombine/truncating-saturate.ll:665
 
 define <2 x i8> @C0zeroVu(<2 x i8> %X, <2 x i8> %y, <2 x i8> %z) {
 ; CHECK-LABEL: @C0zeroVu(
----------------
Double-checking my understanding: this is a miscompile and is fixed by the new ULT check (m_SpecificInt_ICMP)? If so, let's commit that fix first?


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

https://reviews.llvm.org/D108049



More information about the llvm-commits mailing list