@@ -46983,16 +46983,18 @@ static SDValue combineXor(SDNode *N, SelectionDAG &DAG,
46983
46983
if (SDValue RV = foldXorTruncShiftIntoCmp(N, DAG))
46984
46984
return RV;
46985
46985
46986
+ // Fold xor(zext(xor(x,c1)),c2) -> xor(zext(x),xor(zext(c1),c2))
46986
46987
// Fold xor(truncate(xor(x,c1)),c2) -> xor(truncate(x),xor(truncate(c1),c2))
46987
46988
// TODO: Under what circumstances could this be performed in DAGCombine?
46988
- if (N->getOperand(0).getOpcode() == ISD::TRUNCATE &&
46989
+ if ((N->getOperand(0).getOpcode() == ISD::TRUNCATE ||
46990
+ N->getOperand(0).getOpcode() == ISD::ZERO_EXTEND) &&
46989
46991
N->getOperand(0).getOperand(0).getOpcode() == N->getOpcode() &&
46990
46992
isa<ConstantSDNode>(N->getOperand(1)) &&
46991
46993
isa<ConstantSDNode>(N->getOperand(0).getOperand(0).getOperand(1))) {
46992
46994
SDLoc DL(N);
46993
- SDValue TruncateSrc = N->getOperand(0).getOperand(0);
46994
- SDValue LHS = DAG.getNode(ISD::TRUNCATE , DL, VT, TruncateSrc.getOperand(0) );
46995
- SDValue RHS = DAG.getNode(ISD::TRUNCATE , DL, VT, TruncateSrc.getOperand(1) );
46995
+ SDValue TruncExtSrc = N->getOperand(0).getOperand(0);
46996
+ SDValue LHS = DAG.getZExtOrTrunc(TruncExtSrc.getOperand(0) , DL, VT);
46997
+ SDValue RHS = DAG.getZExtOrTrunc(TruncExtSrc.getOperand(1) , DL, VT);
46996
46998
return DAG.getNode(ISD::XOR, DL, VT, LHS,
46997
46999
DAG.getNode(ISD::XOR, DL, VT, RHS, N->getOperand(1)));
46998
47000
}
0 commit comments