1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -instcombine -S < %s | FileCheck %s
4 declare double @llvm.pow.f64(double, double)
5 declare float @llvm.pow.f32(float, float)
6 declare <2 x double> @llvm.pow.v2f64(<2 x double>, <2 x double>)
7 declare <2 x float> @llvm.pow.v2f32(<2 x float>, <2 x float>)
8 declare <4 x float> @llvm.pow.v4f32(<4 x float>, <4 x float>)
9 declare double @pow(double, double)
12 define double @test_simplify_3(double %x) {
13 ; CHECK-LABEL: @test_simplify_3(
14 ; CHECK-NEXT: [[SQUARE:%.*]] = fmul fast double [[X:%.*]], [[X]]
15 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[SQUARE]], [[X]]
16 ; CHECK-NEXT: ret double [[TMP1]]
18 %1 = call fast double @llvm.pow.f64(double %x, double 3.000000e+00)
23 define float @test_simplify_4f(float %x) {
24 ; CHECK-LABEL: @test_simplify_4f(
25 ; CHECK-NEXT: [[SQUARE:%.*]] = fmul fast float [[X:%.*]], [[X]]
26 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[SQUARE]], [[SQUARE]]
27 ; CHECK-NEXT: ret float [[TMP1]]
29 %1 = call fast float @llvm.pow.f32(float %x, float 4.000000e+00)
34 define double @test_simplify_4(double %x) {
35 ; CHECK-LABEL: @test_simplify_4(
36 ; CHECK-NEXT: [[SQUARE:%.*]] = fmul fast double [[X:%.*]], [[X]]
37 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[SQUARE]], [[SQUARE]]
38 ; CHECK-NEXT: ret double [[TMP1]]
40 %1 = call fast double @llvm.pow.f64(double %x, double 4.000000e+00)
44 ; powf(x, <15.0, 15.0>)
45 define <2 x float> @test_simplify_15(<2 x float> %x) {
46 ; CHECK-LABEL: @test_simplify_15(
47 ; CHECK-NEXT: [[SQUARE:%.*]] = fmul fast <2 x float> [[X:%.*]], [[X]]
48 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast <2 x float> [[SQUARE]], [[X]]
49 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast <2 x float> [[TMP1]], [[TMP1]]
50 ; CHECK-NEXT: [[TMP3:%.*]] = fmul fast <2 x float> [[TMP2]], [[TMP2]]
51 ; CHECK-NEXT: [[TMP4:%.*]] = fmul fast <2 x float> [[TMP1]], [[TMP3]]
52 ; CHECK-NEXT: ret <2 x float> [[TMP4]]
54 %1 = call fast <2 x float> @llvm.pow.v2f32(<2 x float> %x, <2 x float> <float 1.500000e+01, float 1.500000e+01>)
59 define <2 x double> @test_simplify_neg_7(<2 x double> %x) {
60 ; CHECK-LABEL: @test_simplify_neg_7(
61 ; CHECK-NEXT: [[SQUARE:%.*]] = fmul fast <2 x double> [[X:%.*]], [[X]]
62 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast <2 x double> [[SQUARE]], [[SQUARE]]
63 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast <2 x double> [[TMP1]], [[X]]
64 ; CHECK-NEXT: [[TMP3:%.*]] = fmul fast <2 x double> [[SQUARE]], [[TMP2]]
65 ; CHECK-NEXT: [[RECIPROCAL:%.*]] = fdiv fast <2 x double> <double 1.000000e+00, double 1.000000e+00>, [[TMP3]]
66 ; CHECK-NEXT: ret <2 x double> [[RECIPROCAL]]
68 %1 = call fast <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double -7.000000e+00, double -7.000000e+00>)
73 define float @test_simplify_neg_19(float %x) {
74 ; CHECK-LABEL: @test_simplify_neg_19(
75 ; CHECK-NEXT: [[SQUARE:%.*]] = fmul fast float [[X:%.*]], [[X]]
76 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[SQUARE]], [[SQUARE]]
77 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float [[TMP1]], [[TMP1]]
78 ; CHECK-NEXT: [[TMP3:%.*]] = fmul fast float [[TMP2]], [[TMP2]]
79 ; CHECK-NEXT: [[TMP4:%.*]] = fmul fast float [[SQUARE]], [[TMP3]]
80 ; CHECK-NEXT: [[TMP5:%.*]] = fmul fast float [[TMP4]], [[X]]
81 ; CHECK-NEXT: [[RECIPROCAL:%.*]] = fdiv fast float 1.000000e+00, [[TMP5]]
82 ; CHECK-NEXT: ret float [[RECIPROCAL]]
84 %1 = call fast float @llvm.pow.f32(float %x, float -1.900000e+01)
89 define double @test_simplify_11_23(double %x) {
90 ; CHECK-LABEL: @test_simplify_11_23(
91 ; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.pow.f64(double [[X:%.*]], double 1.123000e+01)
92 ; CHECK-NEXT: ret double [[TMP1]]
94 %1 = call fast double @llvm.pow.f64(double %x, double 1.123000e+01)
99 define float @test_simplify_32(float %x) {
100 ; CHECK-LABEL: @test_simplify_32(
101 ; CHECK-NEXT: [[SQUARE:%.*]] = fmul fast float [[X:%.*]], [[X]]
102 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[SQUARE]], [[SQUARE]]
103 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float [[TMP1]], [[TMP1]]
104 ; CHECK-NEXT: [[TMP3:%.*]] = fmul fast float [[TMP2]], [[TMP2]]
105 ; CHECK-NEXT: [[TMP4:%.*]] = fmul fast float [[TMP3]], [[TMP3]]
106 ; CHECK-NEXT: ret float [[TMP4]]
108 %1 = call fast float @llvm.pow.f32(float %x, float 3.200000e+01)
113 define double @test_simplify_33(double %x) {
114 ; CHECK-LABEL: @test_simplify_33(
115 ; CHECK-NEXT: [[TMP1:%.*]] = call fast double @llvm.powi.f64(double [[X:%.*]], i32 33)
116 ; CHECK-NEXT: ret double [[TMP1]]
118 %1 = call fast double @llvm.pow.f64(double %x, double 3.300000e+01)
122 ; pow(x, 16.5) with double
123 define double @test_simplify_16_5(double %x) {
124 ; CHECK-LABEL: @test_simplify_16_5(
125 ; CHECK-NEXT: [[SQRT:%.*]] = call fast double @llvm.sqrt.f64(double [[X:%.*]])
126 ; CHECK-NEXT: [[SQUARE:%.*]] = fmul fast double [[X]], [[X]]
127 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[SQUARE]], [[SQUARE]]
128 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast double [[TMP1]], [[TMP1]]
129 ; CHECK-NEXT: [[TMP3:%.*]] = fmul fast double [[TMP2]], [[TMP2]]
130 ; CHECK-NEXT: [[TMP4:%.*]] = fmul fast double [[TMP3]], [[SQRT]]
131 ; CHECK-NEXT: ret double [[TMP4]]
133 %1 = call fast double @llvm.pow.f64(double %x, double 1.650000e+01)
137 ; pow(x, -16.5) with double
138 define double @test_simplify_neg_16_5(double %x) {
139 ; CHECK-LABEL: @test_simplify_neg_16_5(
140 ; CHECK-NEXT: [[SQRT:%.*]] = call fast double @llvm.sqrt.f64(double [[X:%.*]])
141 ; CHECK-NEXT: [[SQUARE:%.*]] = fmul fast double [[X]], [[X]]
142 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[SQUARE]], [[SQUARE]]
143 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast double [[TMP1]], [[TMP1]]
144 ; CHECK-NEXT: [[TMP3:%.*]] = fmul fast double [[TMP2]], [[TMP2]]
145 ; CHECK-NEXT: [[TMP4:%.*]] = fmul fast double [[TMP3]], [[SQRT]]
146 ; CHECK-NEXT: [[RECIPROCAL:%.*]] = fdiv fast double 1.000000e+00, [[TMP4]]
147 ; CHECK-NEXT: ret double [[RECIPROCAL]]
149 %1 = call fast double @llvm.pow.f64(double %x, double -1.650000e+01)
153 ; pow(x, 16.5) with double
154 define double @test_simplify_16_5_libcall(double %x) {
155 ; CHECK-LABEL: @test_simplify_16_5_libcall(
156 ; CHECK-NEXT: [[SQRT:%.*]] = call fast double @sqrt(double [[X:%.*]])
157 ; CHECK-NEXT: [[SQUARE:%.*]] = fmul fast double [[X]], [[X]]
158 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[SQUARE]], [[SQUARE]]
159 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast double [[TMP1]], [[TMP1]]
160 ; CHECK-NEXT: [[TMP3:%.*]] = fmul fast double [[TMP2]], [[TMP2]]
161 ; CHECK-NEXT: [[TMP4:%.*]] = fmul fast double [[TMP3]], [[SQRT]]
162 ; CHECK-NEXT: ret double [[TMP4]]
164 %1 = call fast double @pow(double %x, double 1.650000e+01)
168 ; pow(x, -16.5) with double
169 define double @test_simplify_neg_16_5_libcall(double %x) {
170 ; CHECK-LABEL: @test_simplify_neg_16_5_libcall(
171 ; CHECK-NEXT: [[SQRT:%.*]] = call fast double @sqrt(double [[X:%.*]])
172 ; CHECK-NEXT: [[SQUARE:%.*]] = fmul fast double [[X]], [[X]]
173 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[SQUARE]], [[SQUARE]]
174 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast double [[TMP1]], [[TMP1]]
175 ; CHECK-NEXT: [[TMP3:%.*]] = fmul fast double [[TMP2]], [[TMP2]]
176 ; CHECK-NEXT: [[TMP4:%.*]] = fmul fast double [[TMP3]], [[SQRT]]
177 ; CHECK-NEXT: [[RECIPROCAL:%.*]] = fdiv fast double 1.000000e+00, [[TMP4]]
178 ; CHECK-NEXT: ret double [[RECIPROCAL]]
180 %1 = call fast double @pow(double %x, double -1.650000e+01)
184 ; pow(x, -8.5) with float
185 define float @test_simplify_neg_8_5(float %x) {
186 ; CHECK-LABEL: @test_simplify_neg_8_5(
187 ; CHECK-NEXT: [[SQRT:%.*]] = call fast float @llvm.sqrt.f32(float [[X:%.*]])
188 ; CHECK-NEXT: [[SQUARE:%.*]] = fmul fast float [[X]], [[X]]
189 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[SQUARE]], [[SQUARE]]
190 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float [[TMP1]], [[SQRT]]
191 ; CHECK-NEXT: [[RECIPROCAL:%.*]] = fdiv fast float 1.000000e+00, [[TMP2]]
192 ; CHECK-NEXT: ret float [[RECIPROCAL]]
194 %1 = call fast float @llvm.pow.f32(float %x, float -0.450000e+01)
198 ; pow(x, 7.5) with <2 x double>
199 define <2 x double> @test_simplify_7_5(<2 x double> %x) {
200 ; CHECK-LABEL: @test_simplify_7_5(
201 ; CHECK-NEXT: [[SQRT:%.*]] = call fast <2 x double> @llvm.sqrt.v2f64(<2 x double> [[X:%.*]])
202 ; CHECK-NEXT: [[SQUARE:%.*]] = fmul fast <2 x double> [[X]], [[X]]
203 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast <2 x double> [[SQUARE]], [[SQUARE]]
204 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast <2 x double> [[TMP1]], [[X]]
205 ; CHECK-NEXT: [[TMP3:%.*]] = fmul fast <2 x double> [[SQUARE]], [[TMP2]]
206 ; CHECK-NEXT: [[TMP4:%.*]] = fmul fast <2 x double> [[TMP3]], [[SQRT]]
207 ; CHECK-NEXT: ret <2 x double> [[TMP4]]
209 %1 = call fast <2 x double> @llvm.pow.v2f64(<2 x double> %x, <2 x double> <double 7.500000e+00, double 7.500000e+00>)
213 ; pow(x, 3.5) with <4 x float>
214 define <4 x float> @test_simplify_3_5(<4 x float> %x) {
215 ; CHECK-LABEL: @test_simplify_3_5(
216 ; CHECK-NEXT: [[SQRT:%.*]] = call fast <4 x float> @llvm.sqrt.v4f32(<4 x float> [[X:%.*]])
217 ; CHECK-NEXT: [[SQUARE:%.*]] = fmul fast <4 x float> [[X]], [[X]]
218 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast <4 x float> [[SQUARE]], [[X]]
219 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast <4 x float> [[TMP1]], [[SQRT]]
220 ; CHECK-NEXT: ret <4 x float> [[TMP2]]
222 %1 = call fast <4 x float> @llvm.pow.v4f32(<4 x float> %x, <4 x float> <float 3.500000e+00, float 3.500000e+00, float 3.500000e+00, float 3.500000e+00>)