[PATCH] D108049: [InstCombine] Extend canonicalizeClampLike to handle truncated inputs
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 28 02:37:11 PDT 2021
lebedev.ri added a comment.
Sorry, this should not be taking so long.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:1350-1351
+ if (Cmp00->getType() != X->getType())
+ if (auto *T = dyn_cast<TruncInst>(X))
+ X = T->getOperand(0);
+
----------------
`match(&X, m_TruncOrSelf(m_Value(X)));` ?
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:1427
+ if (X->getType() != Sel0.getType() &&
+ (!isa<Constant>(ReplacementLow) || !isa<Constant>(ReplacementHigh)))
+ return nullptr;
----------------
This accepts constant exprs too. You probably want `m_ImmConstant()` matcher.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:1441
+ MaybeReplacedLow);
+ return Builder.CreateTrunc(MaybeReplacedHigh, Sel0.getType());
}
----------------
Hm, so this now creates one more instruction than before,
but i'm not seeing one more one-use check being added.
Perhaps the original `trunc` should be one-use?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108049/new/
https://reviews.llvm.org/D108049
More information about the llvm-commits
mailing list