1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -disable-simplify-libcalls -instcombine -S | FileCheck %s
4 declare double @llvm.pow.f64(double, double)
5 declare double @pow(double, double)
7 define double @sqrt_libcall(double %x) {
8 ; CHECK-LABEL: @sqrt_libcall(
9 ; CHECK-NEXT: [[RETVAL:%.*]] = call double @pow(double [[X:%.*]], double 5.000000e-01)
10 ; CHECK-NEXT: ret double [[RETVAL]]
12 %retval = call double @pow(double %x, double 0.5)
16 define double @sqrt_intrinsic(double %x) {
17 ; CHECK-LABEL: @sqrt_intrinsic(
18 ; CHECK-NEXT: [[SQRT:%.*]] = call double @llvm.sqrt.f64(double [[X:%.*]])
19 ; CHECK-NEXT: [[ABS:%.*]] = call double @llvm.fabs.f64(double [[SQRT]])
20 ; CHECK-NEXT: [[ISINF:%.*]] = fcmp oeq double [[X]], 0xFFF0000000000000
21 ; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[ISINF]], double 0x7FF0000000000000, double [[ABS]]
22 ; CHECK-NEXT: ret double [[TMP1]]
24 %retval = call double @llvm.pow.f64(double %x, double 0.5)
28 ; Shrinking is disabled too.
30 define float @shrink_libcall(float %f, float %g) {
31 ; CHECK-LABEL: @shrink_libcall(
32 ; CHECK-NEXT: [[DF:%.*]] = fpext float [[F:%.*]] to double
33 ; CHECK-NEXT: [[DG:%.*]] = fpext float [[G:%.*]] to double
34 ; CHECK-NEXT: [[CALL:%.*]] = call fast double @pow(double [[DF]], double [[DG]])
35 ; CHECK-NEXT: [[FR:%.*]] = fptrunc double [[CALL]] to float
36 ; CHECK-NEXT: ret float [[FR]]
38 %df = fpext float %f to double
39 %dg = fpext float %g to double
40 %call = call fast double @pow(double %df, double %dg)
41 %fr = fptrunc double %call to float
45 ; Shrinking is disabled for the intrinsic too.
47 define float @shrink_intrinsic(float %f, float %g) {
48 ; CHECK-LABEL: @shrink_intrinsic(
49 ; CHECK-NEXT: [[DF:%.*]] = fpext float [[F:%.*]] to double
50 ; CHECK-NEXT: [[DG:%.*]] = fpext float [[G:%.*]] to double
51 ; CHECK-NEXT: [[CALL:%.*]] = call fast double @llvm.pow.f64(double [[DF]], double [[DG]])
52 ; CHECK-NEXT: [[FR:%.*]] = fptrunc double [[CALL]] to float
53 ; CHECK-NEXT: ret float [[FR]]
55 %df = fpext float %f to double
56 %dg = fpext float %g to double
57 %call = call fast double @llvm.pow.f64(double %df, double %dg)
58 %fr = fptrunc double %call to float