@@ -7029,84 +7029,6 @@ static unsigned getExtOpcodeForPromotedOp(SDValue Op) {
7029
7029
}
7030
7030
}
7031
7031
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
-
7110
7032
SDValue SITargetLowering::promoteUniformOpToI32(SDValue Op,
7111
7033
DAGCombinerInfo &DCI) const {
7112
7034
const unsigned Opc = Op.getOpcode();
@@ -15322,17 +15244,13 @@ SDValue SITargetLowering::performClampCombine(SDNode *N,
15322
15244
15323
15245
SDValue SITargetLowering::PerformDAGCombine(SDNode *N,
15324
15246
DAGCombinerInfo &DCI) const {
15325
- SelectionDAG &DAG = DCI.DAG;
15326
15247
switch (N->getOpcode()) {
15327
- case ISD::AND:
15328
- if (auto Res = combineAnd(SDValue(N, 0), DCI))
15329
- return Res;
15330
- break;
15331
15248
case ISD::ADD:
15332
15249
case ISD::SUB:
15333
15250
case ISD::SHL:
15334
15251
case ISD::SRL:
15335
15252
case ISD::SRA:
15253
+ case ISD::AND:
15336
15254
case ISD::OR:
15337
15255
case ISD::XOR:
15338
15256
case ISD::MUL:
@@ -15438,6 +15356,7 @@ SDValue SITargetLowering::PerformDAGCombine(SDNode *N,
15438
15356
case AMDGPUISD::CLAMP:
15439
15357
return performClampCombine(N, DCI);
15440
15358
case ISD::SCALAR_TO_VECTOR: {
15359
+ SelectionDAG &DAG = DCI.DAG;
15441
15360
EVT VT = N->getValueType(0);
15442
15361
15443
15362
// v2i16 (scalar_to_vector i16:x) -> v2i16 (bitcast (any_extend i16:x))
@@ -17610,7 +17529,7 @@ SITargetLowering::lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *AI) const {
17610
17529
bool SITargetLowering::hasAndNot(SDValue Op) const {
17611
17530
// Return false if the operation is divergent, as AND-NOT is a scalar-only
17612
17531
// instruction.
17613
- if (Op->isDivergent())
17532
+ if (Op->isDivergent() || !Op->isMachineOpcode() )
17614
17533
return false;
17615
17534
17616
17535
EVT VT = Op.getValueType();
0 commit comments