1 ; RUN: opt < %s -instcombine -enable-double-float-shrink -S | FileCheck %s 2 3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" 4 target triple = "x86_64-unknown-linux-gnu" 5 6 define float @acos_test(float %f) nounwind readnone { 7 ; CHECK: acos_test 8 %conv = fpext float %f to double 9 %call = call double @acos(double %conv) 10 %conv1 = fptrunc double %call to float 11 ret float %conv1 12 ; CHECK: call float @acosf(float %f) 13 } 14 15 define double @acos_test2(float %f) nounwind readnone { 16 ; CHECK: acos_test2 17 %conv = fpext float %f to double 18 %call = call double @acos(double %conv) 19 ret double %call 20 ; CHECK: call double @acos(double %conv) 21 } 22 23 define float @acosh_test(float %f) nounwind readnone { 24 ; CHECK: acosh_test 25 %conv = fpext float %f to double 26 %call = call double @acosh(double %conv) 27 %conv1 = fptrunc double %call to float 28 ret float %conv1 29 ; CHECK: call float @acoshf(float %f) 30 } 31 32 define double @acosh_test2(float %f) nounwind readnone { 33 ; CHECK: acosh_test2 34 %conv = fpext float %f to double 35 %call = call double @acosh(double %conv) 36 ret double %call 37 ; CHECK: call double @acosh(double %conv) 38 } 39 40 define float @asin_test(float %f) nounwind readnone { 41 ; CHECK: asin_test 42 %conv = fpext float %f to double 43 %call = call double @asin(double %conv) 44 %conv1 = fptrunc double %call to float 45 ret float %conv1 46 ; CHECK: call float @asinf(float %f) 47 } 48 49 define double @asin_test2(float %f) nounwind readnone { 50 ; CHECK: asin_test2 51 %conv = fpext float %f to double 52 %call = call double @asin(double %conv) 53 ret double %call 54 ; CHECK: call double @asin(double %conv) 55 } 56 57 define float @asinh_test(float %f) nounwind readnone { 58 ; CHECK: asinh_test 59 %conv = fpext float %f to double 60 %call = call double @asinh(double %conv) 61 %conv1 = fptrunc double %call to float 62 ret float %conv1 63 ; CHECK: call float @asinhf(float %f) 64 } 65 66 define double @asinh_test2(float %f) nounwind readnone { 67 ; CHECK: asinh_test2 68 %conv = fpext float %f to double 69 %call = call double @asinh(double %conv) 70 ret double %call 71 ; CHECK: call double @asinh(double %conv) 72 } 73 74 define float @atan_test(float %f) nounwind readnone { 75 ; CHECK: atan_test 76 %conv = fpext float %f to double 77 %call = call double @atan(double %conv) 78 %conv1 = fptrunc double %call to float 79 ret float %conv1 80 ; CHECK: call float @atanf(float %f) 81 } 82 83 define double @atan_test2(float %f) nounwind readnone { 84 ; CHECK: atan_test2 85 %conv = fpext float %f to double 86 %call = call double @atan(double %conv) 87 ret double %call 88 ; CHECK: call double @atan(double %conv) 89 } 90 define float @atanh_test(float %f) nounwind readnone { 91 ; CHECK: atanh_test 92 %conv = fpext float %f to double 93 %call = call double @atanh(double %conv) 94 %conv1 = fptrunc double %call to float 95 ret float %conv1 96 ; CHECK: call float @atanhf(float %f) 97 } 98 99 define double @atanh_test2(float %f) nounwind readnone { 100 ; CHECK: atanh_test2 101 %conv = fpext float %f to double 102 %call = call double @atanh(double %conv) 103 ret double %call 104 ; CHECK: call double @atanh(double %conv) 105 } 106 define float @cbrt_test(float %f) nounwind readnone { 107 ; CHECK: cbrt_test 108 %conv = fpext float %f to double 109 %call = call double @cbrt(double %conv) 110 %conv1 = fptrunc double %call to float 111 ret float %conv1 112 ; CHECK: call float @cbrtf(float %f) 113 } 114 115 define double @cbrt_test2(float %f) nounwind readnone { 116 ; CHECK: cbrt_test2 117 %conv = fpext float %f to double 118 %call = call double @cbrt(double %conv) 119 ret double %call 120 ; CHECK: call double @cbrt(double %conv) 121 } 122 define float @exp_test(float %f) nounwind readnone { 123 ; CHECK: exp_test 124 %conv = fpext float %f to double 125 %call = call double @exp(double %conv) 126 %conv1 = fptrunc double %call to float 127 ret float %conv1 128 ; CHECK: call float @expf(float %f) 129 } 130 131 define double @exp_test2(float %f) nounwind readnone { 132 ; CHECK: exp_test2 133 %conv = fpext float %f to double 134 %call = call double @exp(double %conv) 135 ret double %call 136 ; CHECK: call double @exp(double %conv) 137 } 138 define float @expm1_test(float %f) nounwind readnone { 139 ; CHECK: expm1_test 140 %conv = fpext float %f to double 141 %call = call double @expm1(double %conv) 142 %conv1 = fptrunc double %call to float 143 ret float %conv1 144 ; CHECK: call float @expm1f(float %f) 145 } 146 147 define double @expm1_test2(float %f) nounwind readnone { 148 ; CHECK: expm1_test2 149 %conv = fpext float %f to double 150 %call = call double @expm1(double %conv) 151 ret double %call 152 ; CHECK: call double @expm1(double %conv) 153 } 154 define float @exp10_test(float %f) nounwind readnone { 155 ; CHECK: exp10_test 156 %conv = fpext float %f to double 157 %call = call double @exp10(double %conv) 158 %conv1 = fptrunc double %call to float 159 ret float %conv1 160 ; FIXME: Re-enable this when Linux allows transforming this again, or when we 161 ; can use builtin attributes to test the transform regardless of OS. 162 ; DISABLED-CHECK: call float @exp10f(float %f) 163 ; CHECK: call double @exp10(double %conv) 164 } 165 166 define double @exp10_test2(float %f) nounwind readnone { 167 ; CHECK: exp10_test2 168 %conv = fpext float %f to double 169 %call = call double @exp10(double %conv) 170 ret double %call 171 ; CHECK: call double @exp10(double %conv) 172 } 173 define float @log_test(float %f) nounwind readnone { 174 ; CHECK: log_test 175 %conv = fpext float %f to double 176 %call = call double @log(double %conv) 177 %conv1 = fptrunc double %call to float 178 ret float %conv1 179 ; CHECK: call float @logf(float %f) 180 } 181 182 define double @log_test2(float %f) nounwind readnone { 183 ; CHECK: log_test2 184 %conv = fpext float %f to double 185 %call = call double @log(double %conv) 186 ret double %call 187 ; CHECK: call double @log(double %conv) 188 } 189 define float @log10_test(float %f) nounwind readnone { 190 ; CHECK: log10_test 191 %conv = fpext float %f to double 192 %call = call double @log10(double %conv) 193 %conv1 = fptrunc double %call to float 194 ret float %conv1 195 ; CHECK: call float @log10f(float %f) 196 } 197 198 define double @log10_test2(float %f) nounwind readnone { 199 ; CHECK: log10_test2 200 %conv = fpext float %f to double 201 %call = call double @log10(double %conv) 202 ret double %call 203 ; CHECK: call double @log10(double %conv) 204 } 205 define float @log1p_test(float %f) nounwind readnone { 206 ; CHECK: log1p_test 207 %conv = fpext float %f to double 208 %call = call double @log1p(double %conv) 209 %conv1 = fptrunc double %call to float 210 ret float %conv1 211 ; CHECK: call float @log1pf(float %f) 212 } 213 214 define double @log1p_test2(float %f) nounwind readnone { 215 ; CHECK: log1p_test2 216 %conv = fpext float %f to double 217 %call = call double @log1p(double %conv) 218 ret double %call 219 ; CHECK: call double @log1p(double %conv) 220 } 221 define float @log2_test(float %f) nounwind readnone { 222 ; CHECK: log2_test 223 %conv = fpext float %f to double 224 %call = call double @log2(double %conv) 225 %conv1 = fptrunc double %call to float 226 ret float %conv1 227 ; CHECK: call float @log2f(float %f) 228 } 229 230 define double @log2_test2(float %f) nounwind readnone { 231 ; CHECK: log2_test2 232 %conv = fpext float %f to double 233 %call = call double @log2(double %conv) 234 ret double %call 235 ; CHECK: call double @log2(double %conv) 236 } 237 define float @logb_test(float %f) nounwind readnone { 238 ; CHECK: logb_test 239 %conv = fpext float %f to double 240 %call = call double @logb(double %conv) 241 %conv1 = fptrunc double %call to float 242 ret float %conv1 243 ; CHECK: call float @logbf(float %f) 244 } 245 246 define double @logb_test2(float %f) nounwind readnone { 247 ; CHECK: logb_test2 248 %conv = fpext float %f to double 249 %call = call double @logb(double %conv) 250 ret double %call 251 ; CHECK: call double @logb(double %conv) 252 } 253 define float @sin_test(float %f) nounwind readnone { 254 ; CHECK: sin_test 255 %conv = fpext float %f to double 256 %call = call double @sin(double %conv) 257 %conv1 = fptrunc double %call to float 258 ret float %conv1 259 ; CHECK: call float @sinf(float %f) 260 } 261 262 define double @sin_test2(float %f) nounwind readnone { 263 ; CHECK: sin_test2 264 %conv = fpext float %f to double 265 %call = call double @sin(double %conv) 266 ret double %call 267 ; CHECK: call double @sin(double %conv) 268 } 269 270 define float @sqrt_test(float %f) nounwind readnone { 271 ; CHECK: sqrt_test 272 %conv = fpext float %f to double 273 %call = call double @sqrt(double %conv) 274 %conv1 = fptrunc double %call to float 275 ret float %conv1 276 ; CHECK: call float @sqrtf(float %f) 277 } 278 279 define float @sqrt_int_test(float %f) nounwind readnone { 280 ; CHECK: sqrt_int_test 281 %conv = fpext float %f to double 282 %call = call double @llvm.sqrt.f64(double %conv) 283 %conv1 = fptrunc double %call to float 284 ret float %conv1 285 ; CHECK: call float @llvm.sqrt.f32(float %f) 286 } 287 288 define double @sqrt_test2(float %f) nounwind readnone { 289 ; CHECK: sqrt_test2 290 %conv = fpext float %f to double 291 %call = call double @sqrt(double %conv) 292 ret double %call 293 ; CHECK: call double @sqrt(double %conv) 294 } 295 define float @tan_test(float %f) nounwind readnone { 296 ; CHECK: tan_test 297 %conv = fpext float %f to double 298 %call = call double @tan(double %conv) 299 %conv1 = fptrunc double %call to float 300 ret float %conv1 301 ; CHECK: call float @tanf(float %f) 302 } 303 304 define double @tan_test2(float %f) nounwind readnone { 305 ; CHECK: tan_test2 306 %conv = fpext float %f to double 307 %call = call double @tan(double %conv) 308 ret double %call 309 ; CHECK: call double @tan(double %conv) 310 } 311 define float @tanh_test(float %f) nounwind readnone { 312 ; CHECK: tanh_test 313 %conv = fpext float %f to double 314 %call = call double @tanh(double %conv) 315 %conv1 = fptrunc double %call to float 316 ret float %conv1 317 ; CHECK: call float @tanhf(float %f) 318 } 319 320 define double @tanh_test2(float %f) nounwind readnone { 321 ; CHECK: tanh_test2 322 %conv = fpext float %f to double 323 %call = call double @tanh(double %conv) 324 ret double %call 325 ; CHECK: call double @tanh(double %conv) 326 } 327 328 declare double @tanh(double) nounwind readnone 329 declare double @tan(double) nounwind readnone 330 declare double @sqrt(double) nounwind readnone 331 declare double @sin(double) nounwind readnone 332 declare double @log2(double) nounwind readnone 333 declare double @log1p(double) nounwind readnone 334 declare double @log10(double) nounwind readnone 335 declare double @log(double) nounwind readnone 336 declare double @logb(double) nounwind readnone 337 declare double @exp10(double) nounwind readnone 338 declare double @expm1(double) nounwind readnone 339 declare double @exp(double) nounwind readnone 340 declare double @cbrt(double) nounwind readnone 341 declare double @atanh(double) nounwind readnone 342 declare double @atan(double) nounwind readnone 343 declare double @acos(double) nounwind readnone 344 declare double @acosh(double) nounwind readnone 345 declare double @asin(double) nounwind readnone 346 declare double @asinh(double) nounwind readnone 347 348 declare double @llvm.sqrt.f64(double) nounwind readnone 349 350