Skip to content

Commit 4e30f81

Browse files
authored
[DAG] visitFREEZE - remove isGuaranteedNotToBeUndefOrPoison assertion (#146490)
Although nice to have to prove the freeze can be moved, this can fail immediately after freeze(op(...)) -> op(freeze(),freeze(),...) creation if any of the new freeze nodes now prevents value tracking from seeing through to the source values (e.g. shift amounts/element indices are in bounds etc.). This will allow us to remove the isGuaranteedNotToBeUndefOrPoison checks inside canCreateUndefOrPoison that were discussed on #146361
1 parent 2ee884a commit 4e30f81

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16714,28 +16714,25 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) {
1671416714
Op = DAG.getFreeze(Op);
1671516715
}
1671616716

16717-
SDValue R;
16718-
if (auto *SVN = dyn_cast<ShuffleVectorSDNode>(N0)) {
16719-
// Special case handling for ShuffleVectorSDNode nodes.
16720-
R = DAG.getVectorShuffle(N0.getValueType(), SDLoc(N0), Ops[0], Ops[1],
16721-
SVN->getMask());
16722-
} else {
16723-
// NOTE: this strips poison generating flags.
16724-
// Folding freeze(op(x, ...)) -> op(freeze(x), ...) does not require nnan,
16725-
// ninf, nsz, or fast.
16726-
// However, contract, reassoc, afn, and arcp should be preserved,
16727-
// as these fast-math flags do not introduce poison values.
16728-
SDNodeFlags SrcFlags = N0->getFlags();
16729-
SDNodeFlags SafeFlags;
16730-
SafeFlags.setAllowContract(SrcFlags.hasAllowContract());
16731-
SafeFlags.setAllowReassociation(SrcFlags.hasAllowReassociation());
16732-
SafeFlags.setApproximateFuncs(SrcFlags.hasApproximateFuncs());
16733-
SafeFlags.setAllowReciprocal(SrcFlags.hasAllowReciprocal());
16734-
R = DAG.getNode(N0.getOpcode(), SDLoc(N0), N0->getVTList(), Ops, SafeFlags);
16735-
}
16736-
assert(DAG.isGuaranteedNotToBeUndefOrPoison(R, /*PoisonOnly*/ false) &&
16737-
"Can't create node that may be undef/poison!");
16738-
return R;
16717+
SDLoc DL(N0);
16718+
16719+
// Special case handling for ShuffleVectorSDNode nodes.
16720+
if (auto *SVN = dyn_cast<ShuffleVectorSDNode>(N0))
16721+
return DAG.getVectorShuffle(N0.getValueType(), DL, Ops[0], Ops[1],
16722+
SVN->getMask());
16723+
16724+
// NOTE: this strips poison generating flags.
16725+
// Folding freeze(op(x, ...)) -> op(freeze(x), ...) does not require nnan,
16726+
// ninf, nsz, or fast.
16727+
// However, contract, reassoc, afn, and arcp should be preserved,
16728+
// as these fast-math flags do not introduce poison values.
16729+
SDNodeFlags SrcFlags = N0->getFlags();
16730+
SDNodeFlags SafeFlags;
16731+
SafeFlags.setAllowContract(SrcFlags.hasAllowContract());
16732+
SafeFlags.setAllowReassociation(SrcFlags.hasAllowReassociation());
16733+
SafeFlags.setApproximateFuncs(SrcFlags.hasApproximateFuncs());
16734+
SafeFlags.setAllowReciprocal(SrcFlags.hasAllowReciprocal());
16735+
return DAG.getNode(N0.getOpcode(), DL, N0->getVTList(), Ops, SafeFlags);
1673916736
}
1674016737

1674116738
/// We know that BV is a build_vector node with Constant, ConstantFP or Undef

0 commit comments

Comments
 (0)