Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 6baa465

Browse files
author
Evandro Menezes
committed
[PATCH] [SLC] Test simplification of pow() for vector types (NFC)
Add test case for the simplification of `pow()` for vector types that D50035 enables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338463 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 1fa19f6 commit 6baa465

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

test/Transforms/InstCombine/pow-1.ll

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
declare float @powf(float, float) nounwind readonly
1717
declare double @pow(double, double) nounwind readonly
18+
declare <2 x float> @llvm.pow.v2f32(<2 x float>, <2 x float>) nounwind readonly
19+
declare <2 x double> @llvm.pow.v2f64(<2 x double>, <2 x double>) nounwind readonly
1820

1921
; Check pow(1.0, x) -> 1.0.
2022

@@ -25,13 +27,27 @@ define float @test_simplify1(float %x) {
2527
; CHECK-NEXT: ret float 1.000000e+00
2628
}
2729

30+
define <2 x float> @test_simplify1v(<2 x float> %x) {
31+
; CHECK-LABEL: @test_simplify1v(
32+
%retval = call <2 x float> @llvm.pow.v2f32(<2 x float> <float 1.0, float 1.0>, <2 x float> %x)
33+
ret <2 x float> %retval
34+
; CHECK-NEXT: ret <2 x float> <float 1.000000e+00, float 1.000000e+00>
35+
}
36+
2837
define double @test_simplify2(double %x) {
2938
; CHECK-LABEL: @test_simplify2(
3039
%retval = call double @pow(double 1.0, double %x)
3140
ret double %retval
3241
; CHECK-NEXT: ret double 1.000000e+00
3342
}
3443

44+
define <2 x double> @test_simplify2v(<2 x double> %x) {
45+
; CHECK-LABEL: @test_simplify2v(
46+
%retval = call <2 x double> @llvm.pow.v2f64(<2 x double> <double 1.0, double 1.0>, <2 x double> %x)
47+
ret <2 x double> %retval
48+
; CHECK-NEXT: ret <2 x double> <double 1.000000e+00, double 1.000000e+00>
49+
}
50+
3551
; Check pow(2.0, x) -> exp2(x).
3652

3753
define float @test_simplify3(float %x) {
@@ -42,6 +58,14 @@ define float @test_simplify3(float %x) {
4258
; CHECK-NEXT: ret float [[EXP2F]]
4359
}
4460

61+
define <2 x float> @test_simplify3v(<2 x float> %x) {
62+
; CHECK-LABEL: @test_simplify3v(
63+
%retval = call <2 x float> @llvm.pow.v2f32(<2 x float> <float 2.0, float 2.0>, <2 x float> %x)
64+
; CHECK-NEXT: [[EXP2F:%[a-z0-9]+]] = call <2 x float> @llvm.exp2.v2f32(<2 x float> %x)
65+
ret <2 x float> %retval
66+
; CHECK-NEXT: ret <2 x float> [[EXP2F]]
67+
}
68+
4569
define double @test_simplify4(double %x) {
4670
; CHECK-LABEL: @test_simplify4(
4771
%retval = call double @pow(double 2.0, double %x)
@@ -50,6 +74,14 @@ define double @test_simplify4(double %x) {
5074
; CHECK-NEXT: ret double [[EXP2]]
5175
}
5276

77+
define <2 x double> @test_simplify4v(<2 x double> %x) {
78+
; CHECK-LABEL: @test_simplify4v(
79+
%retval = call <2 x double> @llvm.pow.v2f64(<2 x double> <double 2.0, double 2.0>, <2 x double> %x)
80+
; CHECK-NEXT: [[EXP2:%[a-z0-9]+]] = call <2 x double> @llvm.exp2.v2f64(<2 x double> %x)
81+
ret <2 x double> %retval
82+
; CHECK-NEXT: ret <2 x double> [[EXP2]]
83+
}
84+
5385
; Check pow(x, 0.0) -> 1.0.
5486

5587
define float @test_simplify5(float %x) {
@@ -59,13 +91,27 @@ define float @test_simplify5(float %x) {
5991
; CHECK-NEXT: ret float 1.000000e+00
6092
}
6193

94+
define <2 x float> @test_simplify5v(<2 x float> %x) {
95+
; CHECK-LABEL: @test_simplify5v(
96+
%retval = call <2 x float> @llvm.pow.v2f32(<2 x float> %x, <2 x float> <float 0.0, float 0.0>)
97+
ret <2 x float> %retval
98+
; CHECK-NEXT: %retval = call <2 x float> @llvm.pow.v2f32(<2 x float> %x, <2 x float> zeroinitializer)
99+
}
100+
62101
define double @test_simplify6(double %x) {
63102
; CHECK-LABEL: @test_simplify6(
64103
%retval = call double @pow(double %x, double 0.0)
65104
ret double %retval
66105
; CHECK-NEXT: ret double 1.000000e+00
67106
}
68107

108+
define <2 x double> @test_simplify6v(<2 x double> %x) {
109+
; CHECK-LABEL: @test_simplify6v(
110+
%retval = call <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double 0.0, double 0.0>)
111+
ret <2 x double> %retval
112+
; CHECK-NEXT: %retval = call <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> zeroinitializer)
113+
}
114+
69115
; Check pow(x, 0.5) -> fabs(sqrt(x)), where x != -infinity.
70116

71117
define float @test_simplify7(float %x) {
@@ -115,13 +161,27 @@ define float @test_simplify11(float %x) {
115161
; CHECK-NEXT: ret float %x
116162
}
117163

164+
define <2 x float> @test_simplify11v(<2 x float> %x) {
165+
; CHECK-LABEL: @test_simplify11v(
166+
%retval = call <2 x float> @llvm.pow.v2f32(<2 x float> %x, <2 x float> <float 1.0, float 1.0>)
167+
ret <2 x float> %retval
168+
; CHECK-NEXT: %retval = call <2 x float> @llvm.pow.v2f32(<2 x float> %x, <2 x float> <float 1.000000e+00, float 1.000000e+00>)
169+
}
170+
118171
define double @test_simplify12(double %x) {
119172
; CHECK-LABEL: @test_simplify12(
120173
%retval = call double @pow(double %x, double 1.0)
121174
ret double %retval
122175
; CHECK-NEXT: ret double %x
123176
}
124177

178+
define <2 x double> @test_simplify12v(<2 x double> %x) {
179+
; CHECK-LABEL: @test_simplify12v(
180+
%retval = call <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double 1.0, double 1.0>)
181+
ret <2 x double> %retval
182+
; CHECK-NEXT: %retval = call <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double 1.000000e+00, double 1.000000e+00>)
183+
}
184+
125185
; Check pow(x, 2.0) -> x*x.
126186

127187
define float @pow2_strict(float %x) {
@@ -133,6 +193,15 @@ define float @pow2_strict(float %x) {
133193
ret float %r
134194
}
135195

196+
define <2 x float> @pow2_strictv(<2 x float> %x) {
197+
; CHECK-LABEL: @pow2_strictv(
198+
; CHECK-NEXT: [[POW2:%.*]] = call <2 x float> @llvm.pow.v2f32(<2 x float> %x, <2 x float> <float 2.000000e+00, float 2.000000e+00>)
199+
; CHECK-NEXT: ret <2 x float> [[POW2]]
200+
;
201+
%r = call <2 x float> @llvm.pow.v2f32(<2 x float> %x, <2 x float> <float 2.0, float 2.0>)
202+
ret <2 x float> %r
203+
}
204+
136205
define double @pow2_double_strict(double %x) {
137206
; CHECK-LABEL: @pow2_double_strict(
138207
; CHECK-NEXT: [[POW2:%.*]] = fmul double %x, %x
@@ -141,6 +210,14 @@ define double @pow2_double_strict(double %x) {
141210
%r = call double @pow(double %x, double 2.0)
142211
ret double %r
143212
}
213+
define <2 x double> @pow2_double_strictv(<2 x double> %x) {
214+
; CHECK-LABEL: @pow2_double_strictv(
215+
; CHECK-NEXT: [[POW2:%.*]] = call <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double 2.000000e+00, double 2.000000e+00>)
216+
; CHECK-NEXT: ret <2 x double> [[POW2]]
217+
;
218+
%r = call <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double 2.0, double 2.0>)
219+
ret <2 x double> %r
220+
}
144221

145222
; Don't drop the FMF - PR35601 ( https://bugs.llvm.org/show_bug.cgi?id=35601 )
146223

@@ -164,6 +241,15 @@ define float @pow_neg1_strict(float %x) {
164241
ret float %r
165242
}
166243

244+
define <2 x float> @pow_neg1_strictv(<2 x float> %x) {
245+
; CHECK-LABEL: @pow_neg1_strictv(
246+
; CHECK-NEXT: [[POWRECIP:%.*]] = call <2 x float> @llvm.pow.v2f32(<2 x float> %x, <2 x float> <float -1.000000e+00, float -1.000000e+00>)
247+
; CHECK-NEXT: ret <2 x float> [[POWRECIP]]
248+
;
249+
%r = call <2 x float> @llvm.pow.v2f32(<2 x float> %x, <2 x float> <float -1.0, float -1.0>)
250+
ret <2 x float> %r
251+
}
252+
167253
define double @pow_neg1_double_fast(double %x) {
168254
; CHECK-LABEL: @pow_neg1_double_fast(
169255
; CHECK-NEXT: [[POWRECIP:%.*]] = fdiv fast double 1.000000e+00, %x
@@ -173,6 +259,15 @@ define double @pow_neg1_double_fast(double %x) {
173259
ret double %r
174260
}
175261

262+
define <2 x double> @pow_neg1_double_fastv(<2 x double> %x) {
263+
; CHECK-LABEL: @pow_neg1_double_fastv(
264+
; CHECK-NEXT: [[POWRECIP:%.*]] = call fast <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double -1.000000e+00, double -1.000000e+00>)
265+
; CHECK-NEXT: ret <2 x double> [[POWRECIP]]
266+
;
267+
%r = call fast <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double -1.0, double -1.0>)
268+
ret <2 x double> %r
269+
}
270+
176271
declare double @llvm.pow.f64(double %Val, double %Power)
177272
define double @test_simplify17(double %x) {
178273
; CHECK-LABEL: @test_simplify17(

0 commit comments

Comments
 (0)