[DAG] getNode() - begin generalizing the (zext (trunc (assertzext x))) -> (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.
This commit is contained in:
Simon Pilgrim 2023-09-18 15:30:00 +01:00
parent aa8601dc6d
commit b2ffc867ad

View File

@ -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;
}