@@ -7029,84 +7029,6 @@ static unsigned getExtOpcodeForPromotedOp(SDValue Op) {
70297029 }
70307030}
70317031
7032- SDValue SITargetLowering::combineAnd(SDValue Op, DAGCombinerInfo &DCI) const {
7033- const unsigned Opc = Op.getOpcode();
7034- assert(Opc == ISD::AND);
7035-
7036- auto &DAG = DCI.DAG;
7037- SDLoc DL(Op);
7038-
7039- if (hasAndNot(Op)) {
7040- SDValue LHS = Op->getOperand(0);
7041- SDValue RHS = Op->getOperand(1);
7042-
7043- // (and LHS, (or Y, ~Z))
7044- if (RHS.getOpcode() == ISD::OR && RHS.hasOneUse()) {
7045- SDValue Y = RHS->getOperand(0);
7046- SDValue NotZ = RHS->getOperand(1);
7047-
7048- if (NotZ.getOpcode() == ISD::XOR &&
7049- isAllOnesConstant(NotZ->getOperand(1))) {
7050- SDValue Z = NotZ->getOperand(0);
7051-
7052- if (!isa<ConstantSDNode>(Y)) {
7053- SDValue NotY = DAG.getNOT(DL, Y, Y.getValueType());
7054- SDValue AndNotYZ =
7055- DAG.getNode(ISD::AND, DL, Y.getValueType(), NotY, Z);
7056- SDValue NotAndNotYZ =
7057- DAG.getNOT(DL, AndNotYZ, AndNotYZ.getValueType());
7058- SDValue NewAnd =
7059- DAG.getNode(ISD::AND, DL, Op.getValueType(), LHS, NotAndNotYZ);
7060- return NewAnd;
7061- }
7062- }
7063- }
7064- }
7065-
7066- EVT OpTy = (Opc != ISD::SETCC) ? Op.getValueType()
7067- : Op->getOperand(0).getValueType();
7068- auto ExtTy = OpTy.changeElementType(MVT::i32);
7069-
7070- if (DCI.isBeforeLegalizeOps() ||
7071- isNarrowingProfitable(Op.getNode(), ExtTy, OpTy))
7072- return SDValue();
7073-
7074- SDValue LHS;
7075- SDValue RHS;
7076- if (Opc == ISD::SELECT) {
7077- LHS = Op->getOperand(1);
7078- RHS = Op->getOperand(2);
7079- } else {
7080- LHS = Op->getOperand(0);
7081- RHS = Op->getOperand(1);
7082- }
7083-
7084- const unsigned ExtOp = getExtOpcodeForPromotedOp(Op);
7085- LHS = DAG.getNode(ExtOp, DL, ExtTy, {LHS});
7086-
7087- // Special case: for shifts, the RHS always needs a zext.
7088- if (Opc == ISD::SHL || Opc == ISD::SRL || Opc == ISD::SRA)
7089- RHS = DAG.getNode(ISD::ZERO_EXTEND, DL, ExtTy, {RHS});
7090- else
7091- RHS = DAG.getNode(ExtOp, DL, ExtTy, {RHS});
7092-
7093- // setcc always return i1/i1 vec so no need to truncate after.
7094- if (Opc == ISD::SETCC) {
7095- ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(2))->get();
7096- return DAG.getSetCC(DL, Op.getValueType(), LHS, RHS, CC);
7097- }
7098-
7099- // For other ops, we extend the operation's return type as well so we need to
7100- // truncate back to the original type.
7101- SDValue NewVal;
7102- if (Opc == ISD::SELECT)
7103- NewVal = DAG.getNode(ISD::SELECT, DL, ExtTy, {Op->getOperand(0), LHS, RHS});
7104- else
7105- NewVal = DAG.getNode(Opc, DL, ExtTy, {LHS, RHS});
7106-
7107- return DAG.getZExtOrTrunc(NewVal, DL, OpTy);
7108- }
7109-
71107032SDValue SITargetLowering::promoteUniformOpToI32(SDValue Op,
71117033 DAGCombinerInfo &DCI) const {
71127034 const unsigned Opc = Op.getOpcode();
@@ -15322,17 +15244,13 @@ SDValue SITargetLowering::performClampCombine(SDNode *N,
1532215244
1532315245SDValue SITargetLowering::PerformDAGCombine(SDNode *N,
1532415246 DAGCombinerInfo &DCI) const {
15325- SelectionDAG &DAG = DCI.DAG;
1532615247 switch (N->getOpcode()) {
15327- case ISD::AND:
15328- if (auto Res = combineAnd(SDValue(N, 0), DCI))
15329- return Res;
15330- break;
1533115248 case ISD::ADD:
1533215249 case ISD::SUB:
1533315250 case ISD::SHL:
1533415251 case ISD::SRL:
1533515252 case ISD::SRA:
15253+ case ISD::AND:
1533615254 case ISD::OR:
1533715255 case ISD::XOR:
1533815256 case ISD::MUL:
@@ -15438,6 +15356,7 @@ SDValue SITargetLowering::PerformDAGCombine(SDNode *N,
1543815356 case AMDGPUISD::CLAMP:
1543915357 return performClampCombine(N, DCI);
1544015358 case ISD::SCALAR_TO_VECTOR: {
15359+ SelectionDAG &DAG = DCI.DAG;
1544115360 EVT VT = N->getValueType(0);
1544215361
1544315362 // v2i16 (scalar_to_vector i16:x) -> v2i16 (bitcast (any_extend i16:x))
@@ -17610,7 +17529,7 @@ SITargetLowering::lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *AI) const {
1761017529bool SITargetLowering::hasAndNot(SDValue Op) const {
1761117530 // Return false if the operation is divergent, as AND-NOT is a scalar-only
1761217531 // instruction.
17613- if (Op->isDivergent())
17532+ if (Op->isDivergent() || !Op->isMachineOpcode() )
1761417533 return false;
1761517534
1761617535 EVT VT = Op.getValueType();
0 commit comments