[llvm] [SelectionDAG] Make sure demanded lanes for AND/MUL-by-zero are frozen (PR #180727)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 10 07:04:45 PST 2026
================
@@ -24273,8 +24273,17 @@ SDValue DAGCombiner::visitINSERT_VECTOR_ELT(SDNode *N) {
// Build the mask and return the corresponding DAG node.
auto BuildMaskAndNode = [&](SDValue TrueVal, SDValue FalseVal,
unsigned MaskOpcode) {
- for (unsigned I = 0; I != NumElts; ++I)
+ APInt InsertedEltMask = APInt::getZero(NumElts);
+ for (unsigned I = 0; I != NumElts; ++I) {
Mask[I] = Ops[I] ? TrueVal : FalseVal;
+ if (Ops[I])
+ InsertedEltMask.setBit(I);
+ }
+ // Make sure to freeze the source vector in case any of the elements
+ // overwritten by the insert may be poison. Otherwise those elements
+ // could end up being poison instead of 0/-1 after the AND/OR.
+ CurVec =
+ DAG.getFreeze(CurVec, InsertedEltMask, /*PoisonOnly=*/true);
----------------
RKSimon wrote:
How much worse is it if we just use the existing getFreeze and then rely on a later SimplifyDemandedVectorElts call to the freeze node to strip them out?
https://github.com/llvm/llvm-project/pull/180727
More information about the llvm-commits
mailing list