Skip to content

Commit a51c29d

Browse files
Addressed the review comments1
1 parent a176e69 commit a51c29d

File tree

5 files changed

+152
-276
lines changed

5 files changed

+152
-276
lines changed

llvm/lib/Target/X86/X86ISelDAGToDAG.cpp

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5456,39 +5456,37 @@ void X86DAGToDAGISel::Select(SDNode *Node) {
54565456
break;
54575457
}
54585458

5459-
case X86ISD::FP_TO_SINT_SAT_CUSTOM:
5460-
case X86ISD::FP_TO_UINT_SAT_CUSTOM:
5461-
if (Subtarget->hasAVX10_2()) {
5462-
bool IsSigned = Node->getOpcode() == X86ISD::FP_TO_SINT_SAT_CUSTOM;
5463-
SDValue Op = Node->getOperand(0);
5464-
EVT VT = Node->getValueType(0);
5465-
EVT OpVT = Op.getValueType();
5466-
MachineSDNode *MachineNode;
5467-
5468-
if (VT == MVT::v4i32 && OpVT == MVT::v4f32) {
5469-
if (IsSigned)
5470-
MachineNode = CurDAG->getMachineNode(X86::VCVTTPD2DQSZ128rr, dl,
5471-
MVT::v4i32, Op);
5472-
else
5473-
MachineNode = CurDAG->getMachineNode(X86::VCVTTPD2UDQSZ128rr, dl,
5474-
MVT::v4i32, Op);
5475-
}
5476-
5477-
if ((VT == MVT::v2i64 && OpVT == MVT::v2f64)) {
5478-
if (IsSigned)
5479-
MachineNode = CurDAG->getMachineNode(X86::VCVTTPS2QQSZ128rr, dl,
5480-
MVT::v2i64, Op);
5481-
else
5482-
MachineNode = CurDAG->getMachineNode(X86::VCVTTPS2UQQSZ128rr, dl,
5483-
MVT::v2i64, Op);
5484-
}
5459+
case X86ISD::FP_TO_SINT_SAT:
5460+
case X86ISD::FP_TO_UINT_SAT: {
5461+
assert(Subtarget->hasAVX10_2() && "Unsupported node");
5462+
bool IsSigned = Node->getOpcode() == X86ISD::FP_TO_SINT_SAT;
5463+
SDValue Op = Node->getOperand(0);
5464+
EVT VT = Node->getValueType(0);
5465+
EVT OpVT = Op.getValueType();
5466+
MachineSDNode *MachineNode;
5467+
5468+
if (VT == MVT::v4i32 && OpVT == MVT::v4f32) {
5469+
if (IsSigned)
5470+
MachineNode =
5471+
CurDAG->getMachineNode(X86::VCVTTPD2DQSZ128rr, dl, MVT::v4i32, Op);
5472+
else
5473+
MachineNode =
5474+
CurDAG->getMachineNode(X86::VCVTTPD2UDQSZ128rr, dl, MVT::v4i32, Op);
5475+
}
54855476

5486-
SDValue NewNode = SDValue(MachineNode, 0);
5487-
ReplaceNode(Node, NewNode.getNode());
5488-
return;
5477+
if ((VT == MVT::v2i64 && OpVT == MVT::v2f64)) {
5478+
if (IsSigned)
5479+
MachineNode =
5480+
CurDAG->getMachineNode(X86::VCVTTPS2QQSZ128rr, dl, MVT::v2i64, Op);
5481+
else
5482+
MachineNode =
5483+
CurDAG->getMachineNode(X86::VCVTTPS2UQQSZ128rr, dl, MVT::v2i64, Op);
54895484
}
5490-
break;
54915485

5486+
SDValue NewNode = SDValue(MachineNode, 0);
5487+
ReplaceNode(Node, NewNode.getNode());
5488+
return;
5489+
}
54925490
case X86ISD::ANDNP:
54935491
if (tryVPTERNLOG(Node))
54945492
return;

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,14 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
344344
setOperationAction(ISD::FP_TO_UINT_SAT, MVT::v2i32, Custom);
345345
setOperationAction(ISD::FP_TO_SINT_SAT, MVT::v2i32, Custom);
346346
for (MVT VT : {MVT::i32, MVT::v4i32, MVT::v8i32, MVT::v16i32, MVT::v2i64,
347-
MVT::v4i64, MVT::v8i64}) {
347+
MVT::v4i64}) {
348348
setOperationAction(ISD::FP_TO_UINT_SAT, VT, Legal);
349349
setOperationAction(ISD::FP_TO_SINT_SAT, VT, Legal);
350350
}
351+
if (Subtarget.hasAVX10_2_512()) {
352+
setOperationAction(ISD::FP_TO_UINT_SAT, MVT::v8i64, Legal);
353+
setOperationAction(ISD::FP_TO_SINT_SAT, MVT::v8i64, Legal);
354+
}
351355
if (Subtarget.is64Bit()) {
352356
setOperationAction(ISD::FP_TO_UINT_SAT, MVT::i64, Legal);
353357
setOperationAction(ISD::FP_TO_SINT_SAT, MVT::i64, Legal);
@@ -33686,11 +33690,9 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
3368633690
if (VT == MVT::v2i32 && OpVT == MVT::v2f64) {
3368733691
SDValue V4f32 = DAG.getNode(X86ISD::VFPROUND, dl, MVT::v4f32, Op);
3368833692
if (IsSigned)
33689-
V4I32 =
33690-
DAG.getNode(X86ISD::FP_TO_SINT_SAT_CUSTOM, dl, MVT::v4i32, V4f32);
33693+
V4I32 = DAG.getNode(X86ISD::FP_TO_SINT_SAT, dl, MVT::v4i32, V4f32);
3369133694
else
33692-
V4I32 =
33693-
DAG.getNode(X86ISD::FP_TO_UINT_SAT_CUSTOM, dl, MVT::v4i32, V4f32);
33695+
V4I32 = DAG.getNode(X86ISD::FP_TO_UINT_SAT, dl, MVT::v4i32, V4f32);
3369433696
Results.push_back(V4I32);
3369533697
return;
3369633698
}
@@ -34676,8 +34678,8 @@ const char *X86TargetLowering::getTargetNodeName(unsigned Opcode) const {
3467634678
NODE_NAME_CASE(VPERMV3)
3467734679
NODE_NAME_CASE(VPERMI)
3467834680
NODE_NAME_CASE(VPTERNLOG)
34679-
NODE_NAME_CASE(FP_TO_SINT_SAT_CUSTOM)
34680-
NODE_NAME_CASE(FP_TO_UINT_SAT_CUSTOM)
34681+
NODE_NAME_CASE(FP_TO_SINT_SAT)
34682+
NODE_NAME_CASE(FP_TO_UINT_SAT)
3468134683
NODE_NAME_CASE(VFIXUPIMM)
3468234684
NODE_NAME_CASE(VFIXUPIMM_SAE)
3468334685
NODE_NAME_CASE(VFIXUPIMMS)
@@ -56251,13 +56253,12 @@ static SDValue combineFP_TO_xINT_SAT(SDNode *N, SelectionDAG &DAG,
5625156253
SDValue V2F64 =
5625256254
DAG.getNode(ISD::FP_EXTEND, dl, MVT::v2f64, N->getOperand(0));
5625356255

56254-
// Select the FP_TO_SINT_SAT_CUSTOM/FP_TO_UINT_SAT_CUSTOM node
56256+
// Select the FP_TO_SINT_SAT/FP_TO_UINT_SAT node
5625556257
if (IsSigned)
56256-
return DAG.getNode(X86ISD::FP_TO_SINT_SAT_CUSTOM, dl, MVT::v2i64, V2F64);
56257-
else
56258-
return DAG.getNode(X86ISD::FP_TO_UINT_SAT_CUSTOM, dl, MVT::v2i64, V2F64);
56259-
}
56258+
return DAG.getNode(X86ISD::FP_TO_SINT_SAT, dl, MVT::v2i64, V2F64);
5626056259

56260+
return DAG.getNode(X86ISD::FP_TO_UINT_SAT, dl, MVT::v2i64, V2F64);
56261+
}
5626156262
return SDValue();
5626256263
}
5626356264

llvm/lib/Target/X86/X86ISelLowering.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,8 @@ namespace llvm {
909909
FLDENVm,
910910

911911
// Custom handling for FP_TO_xINT_SAT
912-
FP_TO_SINT_SAT_CUSTOM,
913-
FP_TO_UINT_SAT_CUSTOM,
912+
FP_TO_SINT_SAT,
913+
FP_TO_UINT_SAT,
914914

915915
/// This instruction implements FP_TO_SINT with the
916916
/// integer destination in memory and a FP reg source. This corresponds
Lines changed: 37 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,85 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc < %s -mtriple=i686-linux -mattr=+avx10.2-512 | FileCheck %s --check-prefix=X86
3-
; RUN: llc < %s -mtriple=x86_64-linux -mattr=+avx10.2-512 | FileCheck %s --check-prefix=X64
2+
; RUN: llc < %s -mtriple=i686-linux -mattr=+avx10.2-512 | FileCheck %s --check-prefixes=CHECK,X86
3+
; RUN: llc < %s -mtriple=x86_64-linux -mattr=+avx10.2-512 | FileCheck %s --check-prefixes=CHECK,X64
44

55
; VCVTTPD2DQS
66
define <8 x i32> @test_signed_v8i32_v8f64(<8 x double> %f) nounwind {
7-
; X86-LABEL: test_signed_v8i32_v8f64:
8-
; X86: # %bb.0:
9-
; X86-NEXT: vcvttpd2dqs %zmm0, %ymm0
10-
; X86-NEXT: retl
11-
;
12-
; X64-LABEL: test_signed_v8i32_v8f64:
13-
; X64: # %bb.0:
14-
; X64-NEXT: vcvttpd2dqs %zmm0, %ymm0
15-
; X64-NEXT: retq
7+
; CHECK-LABEL: test_signed_v8i32_v8f64:
8+
; CHECK: # %bb.0:
9+
; CHECK-NEXT: vcvttpd2dqs %zmm0, %ymm0
10+
; CHECK-NEXT: ret{{[l|q]}}
1611
%x = call <8 x i32> @llvm.fptosi.sat.v8i32.v8f64(<8 x double> %f)
1712
ret <8 x i32> %x
1813
}
1914

2015
; VCVTTPD2QQS
2116
define <8 x i64> @test_signed_v8i64_v8f64(<8 x double> %f) nounwind {
22-
; X86-LABEL: test_signed_v8i64_v8f64:
23-
; X86: # %bb.0:
24-
; X86-NEXT: vcvttpd2qqs %zmm0, %zmm0
25-
; X86-NEXT: retl
26-
;
27-
; X64-LABEL: test_signed_v8i64_v8f64:
28-
; X64: # %bb.0:
29-
; X64-NEXT: vcvttpd2qqs %zmm0, %zmm0
30-
; X64-NEXT: retq
17+
; CHECK-LABEL: test_signed_v8i64_v8f64:
18+
; CHECK: # %bb.0:
19+
; CHECK-NEXT: vcvttpd2qqs %zmm0, %zmm0
20+
; CHECK-NEXT: ret{{[l|q]}}
3121
%x = call <8 x i64> @llvm.fptosi.sat.v8i64.v8f64(<8 x double> %f)
3222
ret <8 x i64> %x
3323
}
3424

3525
; VCVTTPD2UDQS
3626
define <8 x i32> @test_unsigned_v8i32_v8f64(<8 x double> %f) nounwind {
37-
; X86-LABEL: test_unsigned_v8i32_v8f64:
38-
; X86: # %bb.0:
39-
; X86-NEXT: vcvttpd2udqs %zmm0, %ymm0
40-
; X86-NEXT: retl
41-
;
42-
; X64-LABEL: test_unsigned_v8i32_v8f64:
43-
; X64: # %bb.0:
44-
; X64-NEXT: vcvttpd2udqs %zmm0, %ymm0
45-
; X64-NEXT: retq
27+
; CHECK-LABEL: test_unsigned_v8i32_v8f64:
28+
; CHECK: # %bb.0:
29+
; CHECK-NEXT: vcvttpd2udqs %zmm0, %ymm0
30+
; CHECK-NEXT: ret{{[l|q]}}
4631
%x = call <8 x i32> @llvm.fptoui.sat.v8i32.v8f64(<8 x double> %f)
4732
ret <8 x i32> %x
4833
}
4934

5035
; VCVTTPD2UQQS
5136
define <8 x i64> @test_unsigned_v8i64_v8f64(<8 x double> %f) nounwind {
52-
; X86-LABEL: test_unsigned_v8i64_v8f64:
53-
; X86: # %bb.0:
54-
; X86-NEXT: vcvttpd2uqqs %zmm0, %zmm0
55-
; X86-NEXT: retl
56-
;
57-
; X64-LABEL: test_unsigned_v8i64_v8f64:
58-
; X64: # %bb.0:
59-
; X64-NEXT: vcvttpd2uqqs %zmm0, %zmm0
60-
; X64-NEXT: retq
37+
; CHECK-LABEL: test_unsigned_v8i64_v8f64:
38+
; CHECK: # %bb.0:
39+
; CHECK-NEXT: vcvttpd2uqqs %zmm0, %zmm0
40+
; CHECK-NEXT: ret{{[l|q]}}
6141
%x = call <8 x i64> @llvm.fptoui.sat.v8i64.v8f64(<8 x double> %f)
6242
ret <8 x i64> %x
6343
}
6444

6545
; VCVTTPS2DQS
6646
define <16 x i32> @test_signed_v16i32_v16f32(<16 x float> %f) nounwind {
67-
; X86-LABEL: test_signed_v16i32_v16f32:
68-
; X86: # %bb.0:
69-
; X86-NEXT: vcvttps2dqs %zmm0, %zmm0
70-
; X86-NEXT: retl
71-
;
72-
; X64-LABEL: test_signed_v16i32_v16f32:
73-
; X64: # %bb.0:
74-
; X64-NEXT: vcvttps2dqs %zmm0, %zmm0
75-
; X64-NEXT: retq
47+
; CHECK-LABEL: test_signed_v16i32_v16f32:
48+
; CHECK: # %bb.0:
49+
; CHECK-NEXT: vcvttps2dqs %zmm0, %zmm0
50+
; CHECK-NEXT: ret{{[l|q]}}
7651
%x = call <16 x i32> @llvm.fptosi.sat.v16i32.v16f32(<16 x float> %f)
7752
ret <16 x i32> %x
7853
}
7954

8055
; VCVTTPS2UDQS
8156
define <16 x i32> @test_unsigned_v16i32_v16f32(<16 x float> %f) nounwind {
82-
; X86-LABEL: test_unsigned_v16i32_v16f32:
83-
; X86: # %bb.0:
84-
; X86-NEXT: vcvttps2udqs %zmm0, %zmm0
85-
; X86-NEXT: retl
86-
;
87-
; X64-LABEL: test_unsigned_v16i32_v16f32:
88-
; X64: # %bb.0:
89-
; X64-NEXT: vcvttps2udqs %zmm0, %zmm0
90-
; X64-NEXT: retq
57+
; CHECK-LABEL: test_unsigned_v16i32_v16f32:
58+
; CHECK: # %bb.0:
59+
; CHECK-NEXT: vcvttps2udqs %zmm0, %zmm0
60+
; CHECK-NEXT: ret{{[l|q]}}
9161
%x = call <16 x i32> @llvm.fptoui.sat.v16i32.v16f32(<16 x float> %f)
9262
ret <16 x i32> %x
9363
}
9464
; VCVTTPS2QQS
9565
define <8 x i64> @test_signed_v8i64_v8f32(<8 x float> %f) nounwind {
96-
; X86-LABEL: test_signed_v8i64_v8f32:
97-
; X86: # %bb.0:
98-
; X86-NEXT: vcvttps2qqs %ymm0, %zmm0
99-
; X86-NEXT: retl
100-
;
101-
; X64-LABEL: test_signed_v8i64_v8f32:
102-
; X64: # %bb.0:
103-
; X64-NEXT: vcvttps2qqs %ymm0, %zmm0
104-
; X64-NEXT: retq
66+
; CHECK-LABEL: test_signed_v8i64_v8f32:
67+
; CHECK: # %bb.0:
68+
; CHECK-NEXT: vcvttps2qqs %ymm0, %zmm0
69+
; CHECK-NEXT: ret{{[l|q]}}
10570
%x = call <8 x i64> @llvm.fptosi.sat.v8i64.v8f32(<8 x float> %f)
10671
ret <8 x i64> %x
10772
}
10873

10974
; VCVTTPS2UQQS
11075
define <8 x i64> @test_unsigned_v8i64_v8f32(<8 x float> %f) nounwind {
111-
; X86-LABEL: test_unsigned_v8i64_v8f32:
112-
; X86: # %bb.0:
113-
; X86-NEXT: vcvttps2uqqs %ymm0, %zmm0
114-
; X86-NEXT: retl
115-
;
116-
; X64-LABEL: test_unsigned_v8i64_v8f32:
117-
; X64: # %bb.0:
118-
; X64-NEXT: vcvttps2uqqs %ymm0, %zmm0
119-
; X64-NEXT: retq
76+
; CHECK-LABEL: test_unsigned_v8i64_v8f32:
77+
; CHECK: # %bb.0:
78+
; CHECK-NEXT: vcvttps2uqqs %ymm0, %zmm0
79+
; CHECK-NEXT: ret{{[l|q]}}
12080
%x = call <8 x i64> @llvm.fptoui.sat.v8i64.v8f32(<8 x float> %f)
12181
ret <8 x i64> %x
12282
}
83+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
84+
; X64: {{.*}}
85+
; X86: {{.*}}

0 commit comments

Comments
 (0)