Skip to content

Commit a232600

Browse files
[SDAG] [X86] Extend SplitVecOp_VSETCC for STRICT_FSETCCS (#116768)
Closes #116767
1 parent bbafe59 commit a232600

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3235,6 +3235,7 @@ bool DAGTypeLegalizer::SplitVectorOperand(SDNode *N, unsigned OpNo) {
32353235

32363236
case ISD::VP_SETCC:
32373237
case ISD::STRICT_FSETCC:
3238+
case ISD::STRICT_FSETCCS:
32383239
case ISD::SETCC: Res = SplitVecOp_VSETCC(N); break;
32393240
case ISD::BITCAST: Res = SplitVecOp_BITCAST(N); break;
32403241
case ISD::EXTRACT_SUBVECTOR: Res = SplitVecOp_EXTRACT_SUBVECTOR(N); break;
@@ -4236,7 +4237,8 @@ SDValue DAGTypeLegalizer::SplitVecOp_TruncateHelper(SDNode *N) {
42364237
}
42374238

42384239
SDValue DAGTypeLegalizer::SplitVecOp_VSETCC(SDNode *N) {
4239-
bool isStrict = N->getOpcode() == ISD::STRICT_FSETCC;
4240+
unsigned Opc = N->getOpcode();
4241+
bool isStrict = Opc == ISD::STRICT_FSETCC || Opc == ISD::STRICT_FSETCCS;
42404242
assert(N->getValueType(0).isVector() &&
42414243
N->getOperand(isStrict ? 1 : 0).getValueType().isVector() &&
42424244
"Operand types must be vectors");
@@ -4252,21 +4254,19 @@ SDValue DAGTypeLegalizer::SplitVecOp_VSETCC(SDNode *N) {
42524254
EVT PartResVT = EVT::getVectorVT(Context, MVT::i1, PartEltCnt);
42534255
EVT WideResVT = EVT::getVectorVT(Context, MVT::i1, PartEltCnt*2);
42544256

4255-
if (N->getOpcode() == ISD::SETCC) {
4257+
if (Opc == ISD::SETCC) {
42564258
LoRes = DAG.getNode(ISD::SETCC, DL, PartResVT, Lo0, Lo1, N->getOperand(2));
42574259
HiRes = DAG.getNode(ISD::SETCC, DL, PartResVT, Hi0, Hi1, N->getOperand(2));
4258-
} else if (N->getOpcode() == ISD::STRICT_FSETCC) {
4259-
LoRes = DAG.getNode(ISD::STRICT_FSETCC, DL,
4260-
DAG.getVTList(PartResVT, N->getValueType(1)),
4260+
} else if (isStrict) {
4261+
LoRes = DAG.getNode(Opc, DL, DAG.getVTList(PartResVT, N->getValueType(1)),
42614262
N->getOperand(0), Lo0, Lo1, N->getOperand(3));
4262-
HiRes = DAG.getNode(ISD::STRICT_FSETCC, DL,
4263-
DAG.getVTList(PartResVT, N->getValueType(1)),
4263+
HiRes = DAG.getNode(Opc, DL, DAG.getVTList(PartResVT, N->getValueType(1)),
42644264
N->getOperand(0), Hi0, Hi1, N->getOperand(3));
42654265
SDValue NewChain = DAG.getNode(ISD::TokenFactor, DL, MVT::Other,
42664266
LoRes.getValue(1), HiRes.getValue(1));
42674267
ReplaceValueWith(SDValue(N, 1), NewChain);
42684268
} else {
4269-
assert(N->getOpcode() == ISD::VP_SETCC && "Expected VP_SETCC opcode");
4269+
assert(Opc == ISD::VP_SETCC && "Expected VP_SETCC opcode");
42704270
SDValue MaskLo, MaskHi, EVLLo, EVLHi;
42714271
std::tie(MaskLo, MaskHi) = SplitMask(N->getOperand(3));
42724272
std::tie(EVLLo, EVLHi) =

llvm/test/CodeGen/X86/vec-strict-cmp-512-skx.ll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,34 @@ define <8 x i32> @test_v8f64_oeq_q(<8 x i32> %a, <8 x i32> %b, <8 x double> %f1,
3434
ret <8 x i32> %res
3535
}
3636

37+
define <16 x i32> @test_v16f64_ogt(<16 x i32> %a, <16 x i32> %b, <16 x double> %f1, <16 x double> %f2) #0 {
38+
; SKX-LABEL: test_v16f64_ogt
39+
; SKX: # %bb.0:
40+
; SKX-NEXT: pushq %rbp
41+
; SKX-NEXT: movq %rsp, %rbp
42+
; SKX-NEXT: andq $-32, %rsp
43+
; SKX-NEXT: subq $32, %rsp
44+
; SKX-NEXT: vcmpgtpd 80(%rbp), %ymm6, %k0
45+
; SKX-NEXT: vcmpgtpd 112(%rbp), %ymm7, %k1
46+
; SKX-NEXT: kshiftlb $4, %k1, %k1
47+
; SKX-NEXT: korb %k1, %k0, %k1
48+
; SKX-NEXT: vcmpgtpd 16(%rbp), %ymm4, %k0
49+
; SKX-NEXT: vcmpgtpd 48(%rbp), %ymm5, %k2
50+
; SKX-NEXT: kshiftlb $4, %k2, %k2
51+
; SKX-NEXT: korb %k2, %k0, %k2
52+
; SKX-NEXT: vpblendmd %ymm0, %ymm2, %ymm0 {%k2}
53+
; SKX-NEXT: vpblendmd %ymm1, %ymm3, %ymm1 {%k1}
54+
; SKX-NEXT: movq %rbp, %rsp
55+
; SKX-NEXT: popq %rbp
56+
; SKX-NEXT: retq
57+
%cond = tail call <16 x i1> @llvm.experimental.constrained.fcmps.v16f64(
58+
<16 x double> %f1, <16 x double> %f2, metadata !"ogt", metadata !"fpexcept.maytrap")
59+
%res = select <16 x i1> %cond, <16 x i32> %a, <16 x i32> %b
60+
ret <16 x i32> %res
61+
}
62+
3763
declare <16 x i1> @llvm.experimental.constrained.fcmp.v16f32(<16 x float>, <16 x float>, metadata, metadata)
3864
declare <8 x i1> @llvm.experimental.constrained.fcmp.v8f64(<8 x double>, <8 x double>, metadata, metadata)
65+
declare <16 x i1> @llvm.experimental.constrained.fcmps.v16f64(<16 x double>, <16 x double>, metadata, metadata)
3966

4067
attributes #0 = { nounwind strictfp "min-legal-vector-width"="0" }

0 commit comments

Comments
 (0)