[llvm] [InstCombine] Optimize x * !x to 0 for vector #84608 (PR #84792)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 11 09:53:38 PDT 2024
================
@@ -198,6 +198,22 @@ Instruction *InstCombinerImpl::visitMul(BinaryOperator &I) {
if (SimplifyAssociativeOrCommutative(I))
return &I;
+ // mul (sext (icmp eq x, 0)), x -> 0
+ Value *SExtOp, *V0;
+ if ((match(Op0, m_SExt(m_Value(SExtOp))) && match(Op1, m_Value(V0))) ||
+ (match(Op1, m_SExt(m_Value(SExtOp))) && match(Op0, m_Value(V0)))) {
+ Constant *CV;
+ ICmpInst::Predicate Pred;
+ Value *V1;
+ const APInt *IV;
+ if ((match(SExtOp, m_ICmp(Pred, m_Value(V1), m_Constant(CV))) ||
+ match(SExtOp, m_ICmp(Pred, m_Constant(CV), m_Value(V1)))) &&
----------------
topperc wrote:
Constants will get canonicalized to the RHS side. Do we need this check?
https://github.com/llvm/llvm-project/pull/84792
More information about the llvm-commits
mailing list