[llvm] [InstCombine] Propagate demanded elements through fma/fmuladd (PR #221495)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 07:58:10 PDT 2026
================
@@ -1998,6 +1999,27 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
simplifyAndSetOp);
if (V)
return *V;
+
+ // Trivially vectorizable intrinsics operate elementwise: each result lane
+ // uses only the matching lane of the (vector) operands, so the demand
+ // passes through unchanged to every vector operand.
+ Intrinsic::ID IID = II->getIntrinsicID();
+ if (isTriviallyVectorizable(IID)) {
+ APInt PoisonEltsAcc(VWidth, 0);
+ for (Use &Arg : II->args()) {
+ unsigned OpNo = Arg.getOperandNo();
+ // Scalar operands do not carry per-lane demand.
+ if (isVectorIntrinsicWithScalarOpAtArg(IID, OpNo, /*TTI=*/nullptr))
+ continue;
+ APInt OpPoisonElts(VWidth, 0);
+ simplifyAndSetOp(II, OpNo, DemandedElts, OpPoisonElts);
+ PoisonEltsAcc |= OpPoisonElts;
----------------
dtcxzyw wrote:
Do we need to respect undef values here?
https://github.com/llvm/llvm-project/pull/221495
More information about the llvm-commits
mailing list