@@ -6822,84 +6822,6 @@ static unsigned getExtOpcodeForPromotedOp(SDValue Op) {
6822
6822
}
6823
6823
}
6824
6824
6825
- SDValue SITargetLowering::combineAnd(SDValue Op, DAGCombinerInfo &DCI) const {
6826
- const unsigned Opc = Op.getOpcode();
6827
- assert(Opc == ISD::AND);
6828
-
6829
- auto &DAG = DCI.DAG;
6830
- SDLoc DL(Op);
6831
-
6832
- if (hasAndNot(Op)) {
6833
- SDValue LHS = Op->getOperand(0);
6834
- SDValue RHS = Op->getOperand(1);
6835
-
6836
- // (and LHS, (or Y, ~Z))
6837
- if (RHS.getOpcode() == ISD::OR && RHS.hasOneUse()) {
6838
- SDValue Y = RHS->getOperand(0);
6839
- SDValue NotZ = RHS->getOperand(1);
6840
-
6841
- if (NotZ.getOpcode() == ISD::XOR &&
6842
- isAllOnesConstant(NotZ->getOperand(1))) {
6843
- SDValue Z = NotZ->getOperand(0);
6844
-
6845
- if (!isa<ConstantSDNode>(Y)) {
6846
- SDValue NotY = DAG.getNOT(DL, Y, Y.getValueType());
6847
- SDValue AndNotYZ =
6848
- DAG.getNode(ISD::AND, DL, Y.getValueType(), NotY, Z);
6849
- SDValue NotAndNotYZ =
6850
- DAG.getNOT(DL, AndNotYZ, AndNotYZ.getValueType());
6851
- SDValue NewAnd =
6852
- DAG.getNode(ISD::AND, DL, Op.getValueType(), LHS, NotAndNotYZ);
6853
- return NewAnd;
6854
- }
6855
- }
6856
- }
6857
- }
6858
-
6859
- EVT OpTy = (Opc != ISD::SETCC) ? Op.getValueType()
6860
- : Op->getOperand(0).getValueType();
6861
- auto ExtTy = OpTy.changeElementType(MVT::i32);
6862
-
6863
- if (DCI.isBeforeLegalizeOps() ||
6864
- isNarrowingProfitable(Op.getNode(), ExtTy, OpTy))
6865
- return SDValue();
6866
-
6867
- SDValue LHS;
6868
- SDValue RHS;
6869
- if (Opc == ISD::SELECT) {
6870
- LHS = Op->getOperand(1);
6871
- RHS = Op->getOperand(2);
6872
- } else {
6873
- LHS = Op->getOperand(0);
6874
- RHS = Op->getOperand(1);
6875
- }
6876
-
6877
- const unsigned ExtOp = getExtOpcodeForPromotedOp(Op);
6878
- LHS = DAG.getNode(ExtOp, DL, ExtTy, {LHS});
6879
-
6880
- // Special case: for shifts, the RHS always needs a zext.
6881
- if (Opc == ISD::SHL || Opc == ISD::SRL || Opc == ISD::SRA)
6882
- RHS = DAG.getNode(ISD::ZERO_EXTEND, DL, ExtTy, {RHS});
6883
- else
6884
- RHS = DAG.getNode(ExtOp, DL, ExtTy, {RHS});
6885
-
6886
- // setcc always return i1/i1 vec so no need to truncate after.
6887
- if (Opc == ISD::SETCC) {
6888
- ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(2))->get();
6889
- return DAG.getSetCC(DL, Op.getValueType(), LHS, RHS, CC);
6890
- }
6891
-
6892
- // For other ops, we extend the operation's return type as well so we need to
6893
- // truncate back to the original type.
6894
- SDValue NewVal;
6895
- if (Opc == ISD::SELECT)
6896
- NewVal = DAG.getNode(ISD::SELECT, DL, ExtTy, {Op->getOperand(0), LHS, RHS});
6897
- else
6898
- NewVal = DAG.getNode(Opc, DL, ExtTy, {LHS, RHS});
6899
-
6900
- return DAG.getZExtOrTrunc(NewVal, DL, OpTy);
6901
- }
6902
-
6903
6825
SDValue SITargetLowering::promoteUniformOpToI32(SDValue Op,
6904
6826
DAGCombinerInfo &DCI) const {
6905
6827
const unsigned Opc = Op.getOpcode();
@@ -14877,17 +14799,13 @@ SDValue SITargetLowering::performClampCombine(SDNode *N,
14877
14799
14878
14800
SDValue SITargetLowering::PerformDAGCombine(SDNode *N,
14879
14801
DAGCombinerInfo &DCI) const {
14880
- SelectionDAG &DAG = DCI.DAG;
14881
14802
switch (N->getOpcode()) {
14882
- case ISD::AND:
14883
- if (auto Res = combineAnd(SDValue(N, 0), DCI))
14884
- return Res;
14885
- break;
14886
14803
case ISD::ADD:
14887
14804
case ISD::SUB:
14888
14805
case ISD::SHL:
14889
14806
case ISD::SRL:
14890
14807
case ISD::SRA:
14808
+ case ISD::AND:
14891
14809
case ISD::OR:
14892
14810
case ISD::XOR:
14893
14811
case ISD::MUL:
@@ -14991,6 +14909,7 @@ SDValue SITargetLowering::PerformDAGCombine(SDNode *N,
14991
14909
case AMDGPUISD::CLAMP:
14992
14910
return performClampCombine(N, DCI);
14993
14911
case ISD::SCALAR_TO_VECTOR: {
14912
+ SelectionDAG &DAG = DCI.DAG;
14994
14913
EVT VT = N->getValueType(0);
14995
14914
14996
14915
// v2i16 (scalar_to_vector i16:x) -> v2i16 (bitcast (any_extend i16:x))
@@ -16974,7 +16893,7 @@ SITargetLowering::lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *AI) const {
16974
16893
bool SITargetLowering::hasAndNot(SDValue Op) const {
16975
16894
// Return false if the operation is divergent, as AND-NOT is a scalar-only
16976
16895
// instruction.
16977
- if (Op->isDivergent())
16896
+ if (Op->isDivergent() || !Op->isMachineOpcode() )
16978
16897
return false;
16979
16898
16980
16899
EVT VT = Op.getValueType();
0 commit comments