@@ -7049,84 +7049,6 @@ static unsigned getExtOpcodeForPromotedOp(SDValue Op) {
70497049 }
70507050}
70517051
7052- SDValue SITargetLowering::combineAnd(SDValue Op, DAGCombinerInfo &DCI) const {
7053- const unsigned Opc = Op.getOpcode();
7054- assert(Opc == ISD::AND);
7055-
7056- auto &DAG = DCI.DAG;
7057- SDLoc DL(Op);
7058-
7059- if (hasAndNot(Op)) {
7060- SDValue LHS = Op->getOperand(0);
7061- SDValue RHS = Op->getOperand(1);
7062-
7063- // (and LHS, (or Y, ~Z))
7064- if (RHS.getOpcode() == ISD::OR && RHS.hasOneUse()) {
7065- SDValue Y = RHS->getOperand(0);
7066- SDValue NotZ = RHS->getOperand(1);
7067-
7068- if (NotZ.getOpcode() == ISD::XOR &&
7069- isAllOnesConstant(NotZ->getOperand(1))) {
7070- SDValue Z = NotZ->getOperand(0);
7071-
7072- if (!isa<ConstantSDNode>(Y)) {
7073- SDValue NotY = DAG.getNOT(DL, Y, Y.getValueType());
7074- SDValue AndNotYZ =
7075- DAG.getNode(ISD::AND, DL, Y.getValueType(), NotY, Z);
7076- SDValue NotAndNotYZ =
7077- DAG.getNOT(DL, AndNotYZ, AndNotYZ.getValueType());
7078- SDValue NewAnd =
7079- DAG.getNode(ISD::AND, DL, Op.getValueType(), LHS, NotAndNotYZ);
7080- return NewAnd;
7081- }
7082- }
7083- }
7084- }
7085-
7086- EVT OpTy = (Opc != ISD::SETCC) ? Op.getValueType()
7087- : Op->getOperand(0).getValueType();
7088- auto ExtTy = OpTy.changeElementType(MVT::i32);
7089-
7090- if (DCI.isBeforeLegalizeOps() ||
7091- isNarrowingProfitable(Op.getNode(), ExtTy, OpTy))
7092- return SDValue();
7093-
7094- SDValue LHS;
7095- SDValue RHS;
7096- if (Opc == ISD::SELECT) {
7097- LHS = Op->getOperand(1);
7098- RHS = Op->getOperand(2);
7099- } else {
7100- LHS = Op->getOperand(0);
7101- RHS = Op->getOperand(1);
7102- }
7103-
7104- const unsigned ExtOp = getExtOpcodeForPromotedOp(Op);
7105- LHS = DAG.getNode(ExtOp, DL, ExtTy, {LHS});
7106-
7107- // Special case: for shifts, the RHS always needs a zext.
7108- if (Opc == ISD::SHL || Opc == ISD::SRL || Opc == ISD::SRA)
7109- RHS = DAG.getNode(ISD::ZERO_EXTEND, DL, ExtTy, {RHS});
7110- else
7111- RHS = DAG.getNode(ExtOp, DL, ExtTy, {RHS});
7112-
7113- // setcc always return i1/i1 vec so no need to truncate after.
7114- if (Opc == ISD::SETCC) {
7115- ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(2))->get();
7116- return DAG.getSetCC(DL, Op.getValueType(), LHS, RHS, CC);
7117- }
7118-
7119- // For other ops, we extend the operation's return type as well so we need to
7120- // truncate back to the original type.
7121- SDValue NewVal;
7122- if (Opc == ISD::SELECT)
7123- NewVal = DAG.getNode(ISD::SELECT, DL, ExtTy, {Op->getOperand(0), LHS, RHS});
7124- else
7125- NewVal = DAG.getNode(Opc, DL, ExtTy, {LHS, RHS});
7126-
7127- return DAG.getZExtOrTrunc(NewVal, DL, OpTy);
7128- }
7129-
71307052SDValue SITargetLowering::promoteUniformOpToI32(SDValue Op,
71317053 DAGCombinerInfo &DCI) const {
71327054 const unsigned Opc = Op.getOpcode();
@@ -15356,17 +15278,13 @@ SDValue SITargetLowering::performClampCombine(SDNode *N,
1535615278
1535715279SDValue SITargetLowering::PerformDAGCombine(SDNode *N,
1535815280 DAGCombinerInfo &DCI) const {
15359- SelectionDAG &DAG = DCI.DAG;
1536015281 switch (N->getOpcode()) {
15361- case ISD::AND:
15362- if (auto Res = combineAnd(SDValue(N, 0), DCI))
15363- return Res;
15364- break;
1536515282 case ISD::ADD:
1536615283 case ISD::SUB:
1536715284 case ISD::SHL:
1536815285 case ISD::SRL:
1536915286 case ISD::SRA:
15287+ case ISD::AND:
1537015288 case ISD::OR:
1537115289 case ISD::XOR:
1537215290 case ISD::MUL:
@@ -15474,6 +15392,7 @@ SDValue SITargetLowering::PerformDAGCombine(SDNode *N,
1547415392 case AMDGPUISD::CLAMP:
1547515393 return performClampCombine(N, DCI);
1547615394 case ISD::SCALAR_TO_VECTOR: {
15395+ SelectionDAG &DAG = DCI.DAG;
1547715396 EVT VT = N->getValueType(0);
1547815397
1547915398 // v2i16 (scalar_to_vector i16:x) -> v2i16 (bitcast (any_extend i16:x))
@@ -17646,7 +17565,7 @@ SITargetLowering::lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *AI) const {
1764617565bool SITargetLowering::hasAndNot(SDValue Op) const {
1764717566 // Return false if the operation is divergent, as AND-NOT is a scalar-only
1764817567 // instruction.
17649- if (Op->isDivergent())
17568+ if (Op->isDivergent() || !Op->isMachineOpcode() )
1765017569 return false;
1765117570
1765217571 EVT VT = Op.getValueType();
0 commit comments