Skip to content

Commit 5a24dfa

Browse files
authored
[SDAG] Remove most non-canonical libcall handing (#171288)
This is a followup to #171114, removing the handling for most libcalls that are already canonicalized to intrinsics in the middle-end. The only remaining one is fabs, which has more test coverage than the others.
1 parent 036aed0 commit 5a24dfa

22 files changed

+343
-610
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -9590,34 +9590,6 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) {
95909590
if (visitUnaryFloatCall(I, ISD::FABS))
95919591
return;
95929592
break;
9593-
case LibFunc_fmin:
9594-
case LibFunc_fminf:
9595-
case LibFunc_fminl:
9596-
// TODO: Remove this, already canonicalized by the middle-end.
9597-
if (visitBinaryFloatCall(I, ISD::FMINNUM))
9598-
return;
9599-
break;
9600-
case LibFunc_fmax:
9601-
case LibFunc_fmaxf:
9602-
case LibFunc_fmaxl:
9603-
// TODO: Remove this, already canonicalized by the middle-end.
9604-
if (visitBinaryFloatCall(I, ISD::FMAXNUM))
9605-
return;
9606-
break;
9607-
case LibFunc_fminimum_num:
9608-
case LibFunc_fminimum_numf:
9609-
case LibFunc_fminimum_numl:
9610-
// TODO: Remove this, already canonicalized by the middle-end.
9611-
if (visitBinaryFloatCall(I, ISD::FMINIMUMNUM))
9612-
return;
9613-
break;
9614-
case LibFunc_fmaximum_num:
9615-
case LibFunc_fmaximum_numf:
9616-
case LibFunc_fmaximum_numl:
9617-
// TODO: Remove this, already canonicalized by the middle-end.
9618-
if (visitBinaryFloatCall(I, ISD::FMAXIMUMNUM))
9619-
return;
9620-
break;
96219593
case LibFunc_sin:
96229594
case LibFunc_sinf:
96239595
case LibFunc_sinl:
@@ -9687,41 +9659,6 @@ void SelectionDAGBuilder::visitCall(const CallInst &I) {
96879659
if (visitUnaryFloatCall(I, ISD::FSQRT))
96889660
return;
96899661
break;
9690-
case LibFunc_floor:
9691-
case LibFunc_floorf:
9692-
case LibFunc_floorl:
9693-
// TODO: Remove this, already canonicalized by the middle-end.
9694-
if (visitUnaryFloatCall(I, ISD::FFLOOR))
9695-
return;
9696-
break;
9697-
case LibFunc_ceil:
9698-
case LibFunc_ceilf:
9699-
case LibFunc_ceill:
9700-
// TODO: Remove this, already canonicalized by the middle-end.
9701-
if (visitUnaryFloatCall(I, ISD::FCEIL))
9702-
return;
9703-
break;
9704-
case LibFunc_rint:
9705-
case LibFunc_rintf:
9706-
case LibFunc_rintl:
9707-
// TODO: Remove this, already canonicalized by the middle-end.
9708-
if (visitUnaryFloatCall(I, ISD::FRINT))
9709-
return;
9710-
break;
9711-
case LibFunc_round:
9712-
case LibFunc_roundf:
9713-
case LibFunc_roundl:
9714-
// TODO: Remove this, already canonicalized by the middle-end.
9715-
if (visitUnaryFloatCall(I, ISD::FROUND))
9716-
return;
9717-
break;
9718-
case LibFunc_trunc:
9719-
case LibFunc_truncf:
9720-
case LibFunc_truncl:
9721-
// TODO: Remove this, already canonicalized by the middle-end.
9722-
if (visitUnaryFloatCall(I, ISD::FTRUNC))
9723-
return;
9724-
break;
97259662
case LibFunc_log2:
97269663
case LibFunc_log2f:
97279664
case LibFunc_log2l:

llvm/test/CodeGen/AArch64/arm64-rounding.ll

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,19 @@
55
; CHECK-NOT: frintx
66
define float @test1(float %a) #0 {
77
entry:
8-
%call = tail call float @floorf(float %a) nounwind readnone
8+
%call = tail call float @llvm.floor.f32(float %a) nounwind readnone
99
ret float %call
1010
}
1111

12-
declare float @floorf(float) nounwind readnone
13-
1412
; CHECK-LABEL: test2:
1513
; CHECK: frintm
1614
; CHECK-NOT: frintx
1715
define double @test2(double %a) #0 {
1816
entry:
19-
%call = tail call double @floor(double %a) nounwind readnone
17+
%call = tail call double @llvm.floor.f64(double %a) nounwind readnone
2018
ret double %call
2119
}
2220

23-
declare double @floor(double) nounwind readnone
24-
2521
; CHECK-LABEL: test3:
2622
; CHECK: frinti
2723
define float @test3(float %a) #0 {
@@ -43,93 +39,77 @@ entry:
4339
; CHECK-NOT: frintx
4440
define float @test5(float %a) #0 {
4541
entry:
46-
%call = tail call float @ceilf(float %a) nounwind readnone
42+
%call = tail call float @llvm.ceil.f32(float %a) nounwind readnone
4743
ret float %call
4844
}
4945

50-
declare float @ceilf(float) nounwind readnone
51-
5246
; CHECK-LABEL: test6:
5347
; CHECK: frintp
5448
; CHECK-NOT: frintx
5549
define double @test6(double %a) #0 {
5650
entry:
57-
%call = tail call double @ceil(double %a) nounwind readnone
51+
%call = tail call double @llvm.ceil.f64(double %a) nounwind readnone
5852
ret double %call
5953
}
6054

61-
declare double @ceil(double) nounwind readnone
62-
6355
; CHECK-LABEL: test7:
6456
; CHECK: frintx
6557
define float @test7(float %a) #0 {
6658
entry:
67-
%call = tail call float @rintf(float %a) nounwind readnone
59+
%call = tail call float @llvm.rint.f32(float %a) nounwind readnone
6860
ret float %call
6961
}
7062

71-
declare float @rintf(float) nounwind readnone
72-
7363
; CHECK-LABEL: test8:
7464
; CHECK: frintx
7565
define double @test8(double %a) #0 {
7666
entry:
77-
%call = tail call double @rint(double %a) nounwind readnone
67+
%call = tail call double @llvm.rint.f64(double %a) nounwind readnone
7868
ret double %call
7969
}
8070

81-
declare double @rint(double) nounwind readnone
82-
8371
; CHECK-LABEL: test9:
8472
; CHECK: frintz
8573
; CHECK-NOT: frintx
8674
define float @test9(float %a) #0 {
8775
entry:
88-
%call = tail call float @truncf(float %a) nounwind readnone
76+
%call = tail call float @llvm.trunc.f32(float %a) nounwind readnone
8977
ret float %call
9078
}
9179

92-
declare float @truncf(float) nounwind readnone
93-
9480
; CHECK-LABEL: test10:
9581
; CHECK: frintz
9682
; CHECK-NOT: frintx
9783
define double @test10(double %a) #0 {
9884
entry:
99-
%call = tail call double @trunc(double %a) nounwind readnone
85+
%call = tail call double @llvm.trunc.f64(double %a) nounwind readnone
10086
ret double %call
10187
}
10288

103-
declare double @trunc(double) nounwind readnone
104-
10589
; CHECK-LABEL: test11:
10690
; CHECK: frinta
10791
; CHECK-NOT: frintx
10892
define float @test11(float %a) #0 {
10993
entry:
110-
%call = tail call float @roundf(float %a) nounwind readnone
94+
%call = tail call float @llvm.round.f32(float %a) nounwind readnone
11195
ret float %call
11296
}
11397

114-
declare float @roundf(float %a) nounwind readnone
115-
11698
; CHECK-LABEL: test12:
11799
; CHECK: frinta
118100
; CHECK-NOT: frintx
119101
define double @test12(double %a) #0 {
120102
entry:
121-
%call = tail call double @round(double %a) nounwind readnone
103+
%call = tail call double @llvm.round.f64(double %a) nounwind readnone
122104
ret double %call
123105
}
124106

125-
declare double @round(double %a) nounwind readnone
126-
127107
; CHECK-LABEL: test13:
128108
; CHECK-NOT: frintx
129109
; CHECK: frintm
130110
define float @test13(float %a) #1 {
131111
entry:
132-
%call = tail call float @floorf(float %a) nounwind readnone
112+
%call = tail call float @llvm.floor.f32(float %a) nounwind readnone
133113
ret float %call
134114
}
135115

@@ -138,7 +118,7 @@ entry:
138118
; CHECK: frintm
139119
define double @test14(double %a) #1 {
140120
entry:
141-
%call = tail call double @floor(double %a) nounwind readnone
121+
%call = tail call double @llvm.floor.f64(double %a) nounwind readnone
142122
ret double %call
143123
}
144124

@@ -147,7 +127,7 @@ entry:
147127
; CHECK: frintp
148128
define float @test15(float %a) #1 {
149129
entry:
150-
%call = tail call float @ceilf(float %a) nounwind readnone
130+
%call = tail call float @llvm.ceil.f32(float %a) nounwind readnone
151131
ret float %call
152132
}
153133

@@ -156,7 +136,7 @@ entry:
156136
; CHECK: frintp
157137
define double @test16(double %a) #1 {
158138
entry:
159-
%call = tail call double @ceil(double %a) nounwind readnone
139+
%call = tail call double @llvm.ceil.f64(double %a) nounwind readnone
160140
ret double %call
161141
}
162142

@@ -165,7 +145,7 @@ entry:
165145
; CHECK: frintz
166146
define float @test17(float %a) #1 {
167147
entry:
168-
%call = tail call float @truncf(float %a) nounwind readnone
148+
%call = tail call float @llvm.trunc.f32(float %a) nounwind readnone
169149
ret float %call
170150
}
171151

@@ -174,7 +154,7 @@ entry:
174154
; CHECK: frintz
175155
define double @test18(double %a) #1 {
176156
entry:
177-
%call = tail call double @trunc(double %a) nounwind readnone
157+
%call = tail call double @llvm.trunc.f64(double %a) nounwind readnone
178158
ret double %call
179159
}
180160

@@ -183,7 +163,7 @@ entry:
183163
; CHECK: frinta
184164
define float @test19(float %a) #1 {
185165
entry:
186-
%call = tail call float @roundf(float %a) nounwind readnone
166+
%call = tail call float @llvm.round.f32(float %a) nounwind readnone
187167
ret float %call
188168
}
189169

@@ -192,7 +172,7 @@ entry:
192172
; CHECK: frinta
193173
define double @test20(double %a) #1 {
194174
entry:
195-
%call = tail call double @round(double %a) nounwind readnone
175+
%call = tail call double @llvm.round.f64(double %a) nounwind readnone
196176
ret double %call
197177
}
198178

llvm/test/CodeGen/AArch64/floatdp_1source.ll

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@ declare double @fabs(double) readonly
77
declare float @llvm.sqrt.f32(float %Val)
88
declare double @llvm.sqrt.f64(double %Val)
99

10-
declare float @ceilf(float) readonly
11-
declare double @ceil(double) readonly
12-
13-
declare float @floorf(float) readonly
14-
declare double @floor(double) readonly
15-
16-
declare float @truncf(float) readonly
17-
declare double @trunc(double) readonly
18-
19-
declare float @rintf(float) readonly
20-
declare double @rint(double) readonly
21-
2210
define float @fabs_f(float %v) {
2311
; CHECK-LABEL: fabs_f:
2412
; CHECK: ; %bb.0:
@@ -51,7 +39,7 @@ define float @ceil_f(float %v) {
5139
; CHECK: ; %bb.0:
5240
; CHECK-NEXT: frintp s0, s0
5341
; CHECK-NEXT: ret
54-
%r = call float @ceilf(float %v)
42+
%r = call float @llvm.ceil.f32(float %v)
5543
ret float %r
5644
}
5745

@@ -60,7 +48,7 @@ define float @floor_f(float %v) {
6048
; CHECK: ; %bb.0:
6149
; CHECK-NEXT: frintm s0, s0
6250
; CHECK-NEXT: ret
63-
%r = call float @floorf(float %v)
51+
%r = call float @llvm.floor.f32(float %v)
6452
ret float %r
6553
}
6654

@@ -69,7 +57,7 @@ define float @trunc_f(float %v) {
6957
; CHECK: ; %bb.0:
7058
; CHECK-NEXT: frintz s0, s0
7159
; CHECK-NEXT: ret
72-
%r = call float @truncf(float %v)
60+
%r = call float @llvm.trunc.f32(float %v)
7361
ret float %r
7462
}
7563

@@ -78,7 +66,7 @@ define float @rint_f(float %v) {
7866
; CHECK: ; %bb.0:
7967
; CHECK-NEXT: frintx s0, s0
8068
; CHECK-NEXT: ret
81-
%r = call float @rintf(float %v)
69+
%r = call float @llvm.rint.f32(float %v)
8270
ret float %r
8371
}
8472

@@ -123,7 +111,7 @@ define double @ceil_d(double %v) {
123111
; CHECK: ; %bb.0:
124112
; CHECK-NEXT: frintp d0, d0
125113
; CHECK-NEXT: ret
126-
%r = call double @ceil(double %v)
114+
%r = call double @llvm.ceil.f64(double %v)
127115
ret double %r
128116
}
129117

@@ -132,7 +120,7 @@ define double @floor_d(double %v) {
132120
; CHECK: ; %bb.0:
133121
; CHECK-NEXT: frintm d0, d0
134122
; CHECK-NEXT: ret
135-
%r = call double @floor(double %v)
123+
%r = call double @llvm.floor.f64(double %v)
136124
ret double %r
137125
}
138126

@@ -141,7 +129,7 @@ define double @trunc_d(double %v) {
141129
; CHECK: ; %bb.0:
142130
; CHECK-NEXT: frintz d0, d0
143131
; CHECK-NEXT: ret
144-
%r = call double @trunc(double %v)
132+
%r = call double @llvm.trunc.f64(double %v)
145133
ret double %r
146134
}
147135

@@ -150,7 +138,7 @@ define double @rint_d(double %v) {
150138
; CHECK: ; %bb.0:
151139
; CHECK-NEXT: frintx d0, d0
152140
; CHECK-NEXT: ret
153-
%r = call double @rint(double %v)
141+
%r = call double @llvm.rint.f64(double %v)
154142
ret double %r
155143
}
156144

0 commit comments

Comments
 (0)