@@ -814,6 +814,11 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
814
814
setOperationAction(ISD::SETCC, VT, Custom);
815
815
setOperationAction(ISD::CTPOP, VT, Custom);
816
816
setOperationAction(ISD::CTTZ, VT, Custom);
817
+
818
+ // The condition codes aren't legal in SSE/AVX and under AVX512 we use
819
+ // setcc all the way to isel and prefer SETGT in some isel patterns.
820
+ setCondCodeAction(ISD::SETLT, VT, Custom);
821
+ setCondCodeAction(ISD::SETLE, VT, Custom);
817
822
}
818
823
819
824
for (auto VT : { MVT::v16i8, MVT::v8i16, MVT::v4i32 }) {
@@ -1056,6 +1061,11 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
1056
1061
setOperationAction(ISD::CTPOP, VT, Custom);
1057
1062
setOperationAction(ISD::CTTZ, VT, Custom);
1058
1063
setOperationAction(ISD::CTLZ, VT, Custom);
1064
+
1065
+ // The condition codes aren't legal in SSE/AVX and under AVX512 we use
1066
+ // setcc all the way to isel and prefer SETGT in some isel patterns.
1067
+ setCondCodeAction(ISD::SETLT, VT, Custom);
1068
+ setCondCodeAction(ISD::SETLE, VT, Custom);
1059
1069
}
1060
1070
1061
1071
if (Subtarget.hasAnyFMA()) {
@@ -1338,6 +1348,12 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
1338
1348
setOperationAction(ISD::CTTZ, VT, Custom);
1339
1349
setOperationAction(ISD::ROTL, VT, Custom);
1340
1350
setOperationAction(ISD::ROTR, VT, Custom);
1351
+ setOperationAction(ISD::SETCC, VT, Custom);
1352
+
1353
+ // The condition codes aren't legal in SSE/AVX and under AVX512 we use
1354
+ // setcc all the way to isel and prefer SETGT in some isel patterns.
1355
+ setCondCodeAction(ISD::SETLT, VT, Custom);
1356
+ setCondCodeAction(ISD::SETLE, VT, Custom);
1341
1357
}
1342
1358
1343
1359
// Need to promote to 64-bit even though we have 32-bit masked instructions
@@ -1551,6 +1567,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
1551
1567
setOperationAction(ISD::UMAX, VT, Legal);
1552
1568
setOperationAction(ISD::SMIN, VT, Legal);
1553
1569
setOperationAction(ISD::UMIN, VT, Legal);
1570
+ setOperationAction(ISD::SETCC, VT, Custom);
1554
1571
1555
1572
setOperationPromotedToType(ISD::AND, VT, MVT::v8i64);
1556
1573
setOperationPromotedToType(ISD::OR, VT, MVT::v8i64);
@@ -5180,8 +5197,8 @@ static bool isMaskedZeroUpperBitsvXi1(unsigned int Opcode) {
5180
5197
default:
5181
5198
return false;
5182
5199
case X86ISD::CMPM:
5183
- case X86ISD::CMPMU:
5184
5200
case X86ISD::CMPM_RND:
5201
+ case ISD::SETCC:
5185
5202
return true;
5186
5203
}
5187
5204
}
@@ -6978,17 +6995,13 @@ static SDValue lowerBuildVectorAsBroadcast(BuildVectorSDNode *BVOp,
6978
6995
BOperand = ZeroExtended.getOperand(0);
6979
6996
else
6980
6997
BOperand = Ld.getOperand(0).getOperand(0);
6981
- if (BOperand.getValueType().isVector() &&
6982
- BOperand.getSimpleValueType().getVectorElementType() == MVT::i1) {
6983
- if ((EltType == MVT::i64 && (VT.getVectorElementType() == MVT::i8 ||
6984
- NumElts == 8)) || // for broadcastmb2q
6985
- (EltType == MVT::i32 && (VT.getVectorElementType() == MVT::i16 ||
6986
- NumElts == 16))) { // for broadcastmw2d
6987
- SDValue Brdcst =
6988
- DAG.getNode(X86ISD::VBROADCASTM, dl,
6989
- MVT::getVectorVT(EltType, NumElts), BOperand);
6990
- return DAG.getBitcast(VT, Brdcst);
6991
- }
6998
+ MVT MaskVT = BOperand.getSimpleValueType();
6999
+ if ((EltType == MVT::i64 && MaskVT == MVT::v8i1) || // for broadcastmb2q
7000
+ (EltType == MVT::i32 && MaskVT == MVT::v16i1)) { // for broadcastmw2d
7001
+ SDValue Brdcst =
7002
+ DAG.getNode(X86ISD::VBROADCASTM, dl,
7003
+ MVT::getVectorVT(EltType, NumElts), BOperand);
7004
+ return DAG.getBitcast(VT, Brdcst);
6992
7005
}
6993
7006
}
6994
7007
}
@@ -14757,8 +14770,8 @@ static SDValue lower1BitVectorShuffle(const SDLoc &DL, ArrayRef<int> Mask,
14757
14770
int NumElems = VT.getVectorNumElements();
14758
14771
if ((Subtarget.hasBWI() && (NumElems >= 32)) ||
14759
14772
(Subtarget.hasDQI() && (NumElems < 32)))
14760
- return DAG.getNode(X86ISD::CMPM, DL, VT, DAG.getConstant(0, DL, ExtVT),
14761
- Shuffle, DAG.getConstant(6, DL, MVT::i8) );
14773
+ return DAG.getSetCC( DL, VT, DAG.getConstant(0, DL, ExtVT),
14774
+ Shuffle, ISD::SETGT );
14762
14775
14763
14776
return DAG.getNode(ISD::TRUNCATE, DL, VT, Shuffle);
14764
14777
}
@@ -14996,9 +15009,9 @@ SDValue X86TargetLowering::LowerVSELECT(SDValue Op, SelectionDAG &DAG) const {
14996
15009
"Should have a size-matched integer condition!");
14997
15010
// Build a mask by testing the condition against zero.
14998
15011
MVT MaskVT = MVT::getVectorVT(MVT::i1, VT.getVectorNumElements());
14999
- SDValue Mask = DAG.getNode(X86ISD::CMPM, dl, MaskVT, Cond,
15000
- getZeroVector(VT, Subtarget, DAG, dl),
15001
- DAG.getConstant(4, dl, MVT::i8) );
15012
+ SDValue Mask = DAG.getSetCC( dl, MaskVT, Cond,
15013
+ getZeroVector(VT, Subtarget, DAG, dl),
15014
+ ISD::SETNE );
15002
15015
// Now return a new VSELECT using the mask.
15003
15016
return DAG.getSelect(dl, VT, Mask, Op.getOperand(1), Op.getOperand(2));
15004
15017
}
@@ -16962,8 +16975,8 @@ static SDValue LowerTruncateVecI1(SDValue Op, SelectionDAG &DAG,
16962
16975
DAG.getConstant(ShiftInx, DL, ExtVT));
16963
16976
In = DAG.getBitcast(InVT, In);
16964
16977
}
16965
- return DAG.getNode(X86ISD::CMPM, DL, VT, DAG.getConstant(0, DL, InVT),
16966
- In, DAG.getConstant(6, DL, MVT::i8) );
16978
+ return DAG.getSetCC( DL, VT, DAG.getConstant(0, DL, InVT),
16979
+ In, ISD::SETGT );
16967
16980
}
16968
16981
// Use TESTD/Q, extended vector to packed dword/qword.
16969
16982
assert((InVT.is256BitVector() || InVT.is128BitVector()) &&
@@ -17010,11 +17023,10 @@ static SDValue LowerTruncateVecI1(SDValue Op, SelectionDAG &DAG,
17010
17023
}
17011
17024
// If we have DQI, emit a pattern that will be iseled as vpmovq2m/vpmovd2m.
17012
17025
if (Subtarget.hasDQI())
17013
- return DAG.getNode(X86ISD::CMPM, DL, VT, DAG.getConstant(0, DL, InVT),
17014
- In, DAG.getConstant(6, DL, MVT::i8));
17015
- return DAG.getNode(X86ISD::CMPM, DL, VT, In,
17016
- getZeroVector(InVT, Subtarget, DAG, DL),
17017
- DAG.getConstant(4, DL, MVT::i8));
17026
+ return DAG.getSetCC(DL, VT, DAG.getConstant(0, DL, InVT),
17027
+ In, ISD::SETGT);
17028
+ return DAG.getSetCC(DL, VT, In, getZeroVector(InVT, Subtarget, DAG, DL),
17029
+ ISD::SETNE);
17018
17030
}
17019
17031
17020
17032
SDValue X86TargetLowering::LowerTRUNCATE(SDValue Op, SelectionDAG &DAG) const {
@@ -18091,28 +18103,13 @@ static SDValue LowerIntVSETCC_AVX512(SDValue Op, SelectionDAG &DAG) {
18091
18103
ISD::isBuildVectorAllZeros(Op0.getNode()))
18092
18104
std::swap(Op0, Op1);
18093
18105
18094
- bool Swap = false;
18095
- unsigned SSECC;
18096
- switch (SetCCOpcode) {
18097
- default: llvm_unreachable("Unexpected SETCC condition");
18098
- case ISD::SETNE: SSECC = 4; break;
18099
- case ISD::SETEQ: SSECC = 0; break;
18100
- case ISD::SETULT: SSECC = 1; break;
18101
- case ISD::SETLT: Swap = true; LLVM_FALLTHROUGH;
18102
- case ISD::SETUGT:
18103
- case ISD::SETGT: SSECC = 6; break;
18104
- case ISD::SETUGE:
18105
- case ISD::SETGE: SSECC = 5; break;
18106
- case ISD::SETULE:
18107
- case ISD::SETLE: SSECC = 2; break;
18108
- }
18109
- if (Swap)
18106
+ // Prefer SETGT over SETLT.
18107
+ if (SetCCOpcode == ISD::SETLT) {
18108
+ SetCCOpcode = ISD::getSetCCSwappedOperands(SetCCOpcode);
18110
18109
std::swap(Op0, Op1);
18110
+ }
18111
18111
18112
- unsigned Opc = ISD::isUnsignedIntSetCC(SetCCOpcode) ? X86ISD::CMPMU
18113
- : X86ISD::CMPM;
18114
- return DAG.getNode(Opc, dl, VT, Op0, Op1,
18115
- DAG.getConstant(SSECC, dl, MVT::i8));
18112
+ return DAG.getSetCC(dl, VT, Op0, Op1, SetCCOpcode);
18116
18113
}
18117
18114
18118
18115
/// Try to turn a VSETULT into a VSETULE by modifying its second
@@ -20167,7 +20164,6 @@ static SDValue getVectorMaskingNode(SDValue Op, SDValue Mask,
20167
20164
default: break;
20168
20165
case X86ISD::CMPM:
20169
20166
case X86ISD::CMPM_RND:
20170
- case X86ISD::CMPMU:
20171
20167
case X86ISD::VPSHUFBITQMB:
20172
20168
case X86ISD::VFPCLASS:
20173
20169
return DAG.getNode(ISD::AND, dl, VT, Op, VMask);
@@ -22978,8 +22974,8 @@ static SDValue LowerScalarImmediateShift(SDValue Op, SelectionDAG &DAG,
22978
22974
SDValue Zeros = getZeroVector(VT, Subtarget, DAG, dl);
22979
22975
if (VT.is512BitVector()) {
22980
22976
assert(VT == MVT::v64i8 && "Unexpected element type!");
22981
- SDValue CMP = DAG.getNode(X86ISD::CMPM, dl, MVT::v64i1, Zeros, R,
22982
- DAG.getConstant(6, dl, MVT::i8) );
22977
+ SDValue CMP = DAG.getSetCC( dl, MVT::v64i1, Zeros, R,
22978
+ ISD::SETGT );
22983
22979
return DAG.getNode(ISD::SIGN_EXTEND, dl, VT, CMP);
22984
22980
}
22985
22981
return DAG.getNode(X86ISD::PCMPGT, dl, VT, Zeros, R);
@@ -23499,9 +23495,8 @@ static SDValue LowerShift(SDValue Op, const X86Subtarget &Subtarget,
23499
23495
V0 = DAG.getBitcast(VT, V0);
23500
23496
V1 = DAG.getBitcast(VT, V1);
23501
23497
Sel = DAG.getBitcast(VT, Sel);
23502
- Sel = DAG.getNode(X86ISD::CMPM, dl, MaskVT,
23503
- DAG.getConstant(0, dl, VT), Sel,
23504
- DAG.getConstant(6, dl, MVT::i8));
23498
+ Sel = DAG.getSetCC(dl, MaskVT, DAG.getConstant(0, dl, VT), Sel,
23499
+ ISD::SETGT);
23505
23500
return DAG.getBitcast(SelVT, DAG.getSelect(dl, VT, Sel, V0, V1));
23506
23501
} else if (Subtarget.hasSSE41()) {
23507
23502
// On SSE41 targets we make use of the fact that VSELECT lowers
@@ -25716,7 +25711,6 @@ const char *X86TargetLowering::getTargetNodeName(unsigned Opcode) const {
25716
25711
case X86ISD::COMI: return "X86ISD::COMI";
25717
25712
case X86ISD::UCOMI: return "X86ISD::UCOMI";
25718
25713
case X86ISD::CMPM: return "X86ISD::CMPM";
25719
- case X86ISD::CMPMU: return "X86ISD::CMPMU";
25720
25714
case X86ISD::CMPM_RND: return "X86ISD::CMPM_RND";
25721
25715
case X86ISD::SETCC: return "X86ISD::SETCC";
25722
25716
case X86ISD::SETCC_CARRY: return "X86ISD::SETCC_CARRY";
0 commit comments