Skip to content

Commit

Permalink
[DAG] getNode() - begin generalizing the (zext (trunc (assertzext x))…
Browse files Browse the repository at this point in the history
…) -> (assertzext x) fold.

We'll need to generalize this fold to check for any zero upperbits to address some of the D155472 regressions, but this exposes a number of issues. For now, just use the general MaskedValueIsZero test instead of the assertzext.
  • Loading branch information
RKSimon committed Sep 18, 2023
1 parent aa8601d commit b2ffc86
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5695,8 +5695,9 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
SDValue OpOp = N1.getOperand(0);
if (OpOp.getValueType() == VT) {
if (OpOp.getOpcode() == ISD::AssertZext && N1->hasOneUse()) {
EVT ExtVT = cast<VTSDNode>(OpOp.getOperand(1))->getVT();
if (N1.getScalarValueSizeInBits() >= ExtVT.getSizeInBits()) {
APInt HiBits = APInt::getBitsSetFrom(VT.getScalarSizeInBits(),
N1.getScalarValueSizeInBits());
if (MaskedValueIsZero(OpOp, HiBits)) {
transferDbgValues(N1, OpOp);
return OpOp;
}
Expand Down

0 comments on commit b2ffc86

Please sign in to comment.