@@ -7061,84 +7061,6 @@ static unsigned getExtOpcodeForPromotedOp(SDValue Op) {
7061
7061
}
7062
7062
}
7063
7063
7064
- SDValue SITargetLowering::combineAnd(SDValue Op, DAGCombinerInfo &DCI) const {
7065
- const unsigned Opc = Op.getOpcode();
7066
- assert(Opc == ISD::AND);
7067
-
7068
- auto &DAG = DCI.DAG;
7069
- SDLoc DL(Op);
7070
-
7071
- if (hasAndNot(Op)) {
7072
- SDValue LHS = Op->getOperand(0);
7073
- SDValue RHS = Op->getOperand(1);
7074
-
7075
- // (and LHS, (or Y, ~Z))
7076
- if (RHS.getOpcode() == ISD::OR && RHS.hasOneUse()) {
7077
- SDValue Y = RHS->getOperand(0);
7078
- SDValue NotZ = RHS->getOperand(1);
7079
-
7080
- if (NotZ.getOpcode() == ISD::XOR &&
7081
- isAllOnesConstant(NotZ->getOperand(1))) {
7082
- SDValue Z = NotZ->getOperand(0);
7083
-
7084
- if (!isa<ConstantSDNode>(Y)) {
7085
- SDValue NotY = DAG.getNOT(DL, Y, Y.getValueType());
7086
- SDValue AndNotYZ =
7087
- DAG.getNode(ISD::AND, DL, Y.getValueType(), NotY, Z);
7088
- SDValue NotAndNotYZ =
7089
- DAG.getNOT(DL, AndNotYZ, AndNotYZ.getValueType());
7090
- SDValue NewAnd =
7091
- DAG.getNode(ISD::AND, DL, Op.getValueType(), LHS, NotAndNotYZ);
7092
- return NewAnd;
7093
- }
7094
- }
7095
- }
7096
- }
7097
-
7098
- EVT OpTy = (Opc != ISD::SETCC) ? Op.getValueType()
7099
- : Op->getOperand(0).getValueType();
7100
- auto ExtTy = OpTy.changeElementType(MVT::i32);
7101
-
7102
- if (DCI.isBeforeLegalizeOps() ||
7103
- isNarrowingProfitable(Op.getNode(), ExtTy, OpTy))
7104
- return SDValue();
7105
-
7106
- SDValue LHS;
7107
- SDValue RHS;
7108
- if (Opc == ISD::SELECT) {
7109
- LHS = Op->getOperand(1);
7110
- RHS = Op->getOperand(2);
7111
- } else {
7112
- LHS = Op->getOperand(0);
7113
- RHS = Op->getOperand(1);
7114
- }
7115
-
7116
- const unsigned ExtOp = getExtOpcodeForPromotedOp(Op);
7117
- LHS = DAG.getNode(ExtOp, DL, ExtTy, {LHS});
7118
-
7119
- // Special case: for shifts, the RHS always needs a zext.
7120
- if (Opc == ISD::SHL || Opc == ISD::SRL || Opc == ISD::SRA)
7121
- RHS = DAG.getNode(ISD::ZERO_EXTEND, DL, ExtTy, {RHS});
7122
- else
7123
- RHS = DAG.getNode(ExtOp, DL, ExtTy, {RHS});
7124
-
7125
- // setcc always return i1/i1 vec so no need to truncate after.
7126
- if (Opc == ISD::SETCC) {
7127
- ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(2))->get();
7128
- return DAG.getSetCC(DL, Op.getValueType(), LHS, RHS, CC);
7129
- }
7130
-
7131
- // For other ops, we extend the operation's return type as well so we need to
7132
- // truncate back to the original type.
7133
- SDValue NewVal;
7134
- if (Opc == ISD::SELECT)
7135
- NewVal = DAG.getNode(ISD::SELECT, DL, ExtTy, {Op->getOperand(0), LHS, RHS});
7136
- else
7137
- NewVal = DAG.getNode(Opc, DL, ExtTy, {LHS, RHS});
7138
-
7139
- return DAG.getZExtOrTrunc(NewVal, DL, OpTy);
7140
- }
7141
-
7142
7064
SDValue SITargetLowering::promoteUniformOpToI32(SDValue Op,
7143
7065
DAGCombinerInfo &DCI) const {
7144
7066
const unsigned Opc = Op.getOpcode();
@@ -15372,17 +15294,13 @@ SDValue SITargetLowering::performClampCombine(SDNode *N,
15372
15294
15373
15295
SDValue SITargetLowering::PerformDAGCombine(SDNode *N,
15374
15296
DAGCombinerInfo &DCI) const {
15375
- SelectionDAG &DAG = DCI.DAG;
15376
15297
switch (N->getOpcode()) {
15377
- case ISD::AND:
15378
- if (auto Res = combineAnd(SDValue(N, 0), DCI))
15379
- return Res;
15380
- break;
15381
15298
case ISD::ADD:
15382
15299
case ISD::SUB:
15383
15300
case ISD::SHL:
15384
15301
case ISD::SRL:
15385
15302
case ISD::SRA:
15303
+ case ISD::AND:
15386
15304
case ISD::OR:
15387
15305
case ISD::XOR:
15388
15306
case ISD::MUL:
@@ -15490,6 +15408,7 @@ SDValue SITargetLowering::PerformDAGCombine(SDNode *N,
15490
15408
case AMDGPUISD::CLAMP:
15491
15409
return performClampCombine(N, DCI);
15492
15410
case ISD::SCALAR_TO_VECTOR: {
15411
+ SelectionDAG &DAG = DCI.DAG;
15493
15412
EVT VT = N->getValueType(0);
15494
15413
15495
15414
// v2i16 (scalar_to_vector i16:x) -> v2i16 (bitcast (any_extend i16:x))
@@ -17662,7 +17581,7 @@ SITargetLowering::lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *AI) const {
17662
17581
bool SITargetLowering::hasAndNot(SDValue Op) const {
17663
17582
// Return false if the operation is divergent, as AND-NOT is a scalar-only
17664
17583
// instruction.
17665
- if (Op->isDivergent())
17584
+ if (Op->isDivergent() || !Op->isMachineOpcode() )
17666
17585
return false;
17667
17586
17668
17587
EVT VT = Op.getValueType();
0 commit comments