1; RUN: opt < %s -instsimplify -S | FileCheck %s 2; RUN: opt < %s -instsimplify -disable-simplify-libcalls -S | FileCheck %s --check-prefix=FNOBUILTIN 3 4declare double @acos(double) readnone nounwind 5declare double @asin(double) readnone nounwind 6declare double @atan(double) readnone nounwind 7declare double @atan2(double, double) readnone nounwind 8declare double @ceil(double) readnone nounwind 9declare double @cos(double) readnone nounwind 10declare double @cosh(double) readnone nounwind 11declare double @exp(double) readnone nounwind 12declare double @exp2(double) readnone nounwind 13declare double @fabs(double) readnone nounwind 14declare double @floor(double) readnone nounwind 15declare double @fmod(double, double) readnone nounwind 16declare double @log(double) readnone nounwind 17declare double @log10(double) readnone nounwind 18declare double @pow(double, double) readnone nounwind 19declare double @round(double) readnone nounwind 20declare double @sin(double) readnone nounwind 21declare double @sinh(double) readnone nounwind 22declare double @sqrt(double) readnone nounwind 23declare double @tan(double) readnone nounwind 24declare double @tanh(double) readnone nounwind 25 26declare float @acosf(float) readnone nounwind 27declare float @asinf(float) readnone nounwind 28declare float @atanf(float) readnone nounwind 29declare float @atan2f(float, float) readnone nounwind 30declare float @ceilf(float) readnone nounwind 31declare float @cosf(float) readnone nounwind 32declare float @coshf(float) readnone nounwind 33declare float @expf(float) readnone nounwind 34declare float @exp2f(float) readnone nounwind 35declare float @fabsf(float) readnone nounwind 36declare float @floorf(float) readnone nounwind 37declare float @fmodf(float, float) readnone nounwind 38declare float @logf(float) readnone nounwind 39declare float @log10f(float) readnone nounwind 40declare float @powf(float, float) readnone nounwind 41declare float @roundf(float) readnone nounwind 42declare float @sinf(float) readnone nounwind 43declare float @sinhf(float) readnone nounwind 44declare float @sqrtf(float) readnone nounwind 45declare float @tanf(float) readnone nounwind 46declare float @tanhf(float) readnone nounwind 47 48define double @T() { 49; CHECK-LABEL: @T( 50; FNOBUILTIN-LABEL: @T( 51 52; CHECK-NOT: call 53; CHECK: ret 54 %A = call double @cos(double 0.000000e+00) 55 %B = call double @sin(double 0.000000e+00) 56 %a = fadd double %A, %B 57 %C = call double @tan(double 0.000000e+00) 58 %b = fadd double %a, %C 59 %D = call double @sqrt(double 4.000000e+00) 60 %c = fadd double %b, %D 61 62 %slot = alloca double 63 %slotf = alloca float 64; FNOBUILTIN: call 65 %1 = call double @acos(double 1.000000e+00) 66 store double %1, double* %slot 67; FNOBUILTIN: call 68 %2 = call double @asin(double 1.000000e+00) 69 store double %2, double* %slot 70; FNOBUILTIN: call 71 %3 = call double @atan(double 3.000000e+00) 72 store double %3, double* %slot 73; FNOBUILTIN: call 74 %4 = call double @atan2(double 3.000000e+00, double 4.000000e+00) 75 store double %4, double* %slot 76; FNOBUILTIN: call 77 %5 = call double @ceil(double 3.000000e+00) 78 store double %5, double* %slot 79; FNOBUILTIN: call 80 %6 = call double @cosh(double 3.000000e+00) 81 store double %6, double* %slot 82; FNOBUILTIN: call 83 %7 = call double @exp(double 3.000000e+00) 84 store double %7, double* %slot 85; FNOBUILTIN: call 86 %8 = call double @exp2(double 3.000000e+00) 87 store double %8, double* %slot 88; FNOBUILTIN: call 89 %9 = call double @fabs(double 3.000000e+00) 90 store double %9, double* %slot 91; FNOBUILTIN: call 92 %10 = call double @floor(double 3.000000e+00) 93 store double %10, double* %slot 94; FNOBUILTIN: call 95 %11 = call double @fmod(double 3.000000e+00, double 4.000000e+00) 96 store double %11, double* %slot 97; FNOBUILTIN: call 98 %12 = call double @log(double 3.000000e+00) 99 store double %12, double* %slot 100; FNOBUILTIN: call 101 %13 = call double @log10(double 3.000000e+00) 102 store double %13, double* %slot 103; FNOBUILTIN: call 104 %14 = call double @pow(double 3.000000e+00, double 4.000000e+00) 105 store double %14, double* %slot 106; FNOBUILTIN: call 107 %round_val = call double @round(double 3.000000e+00) 108 store double %round_val, double* %slot 109; FNOBUILTIN: call 110 %15 = call double @sinh(double 3.000000e+00) 111 store double %15, double* %slot 112; FNOBUILTIN: call 113 %16 = call double @tanh(double 3.000000e+00) 114 store double %16, double* %slot 115; FNOBUILTIN: call 116 %17 = call float @acosf(float 1.000000e+00) 117 store float %17, float* %slotf 118; FNOBUILTIN: call 119 %18 = call float @asinf(float 1.000000e+00) 120 store float %18, float* %slotf 121; FNOBUILTIN: call 122 %19 = call float @atanf(float 3.000000e+00) 123 store float %19, float* %slotf 124; FNOBUILTIN: call 125 %20 = call float @atan2f(float 3.000000e+00, float 4.000000e+00) 126 store float %20, float* %slotf 127; FNOBUILTIN: call 128 %21 = call float @ceilf(float 3.000000e+00) 129 store float %21, float* %slotf 130; FNOBUILTIN: call 131 %22 = call float @cosf(float 3.000000e+00) 132 store float %22, float* %slotf 133; FNOBUILTIN: call 134 %23 = call float @coshf(float 3.000000e+00) 135 store float %23, float* %slotf 136; FNOBUILTIN: call 137 %24 = call float @expf(float 3.000000e+00) 138 store float %24, float* %slotf 139; FNOBUILTIN: call 140 %25 = call float @exp2f(float 3.000000e+00) 141 store float %25, float* %slotf 142; FNOBUILTIN: call 143 %26 = call float @fabsf(float 3.000000e+00) 144 store float %26, float* %slotf 145; FNOBUILTIN: call 146 %27 = call float @floorf(float 3.000000e+00) 147 store float %27, float* %slotf 148; FNOBUILTIN: call 149 %28 = call float @fmodf(float 3.000000e+00, float 4.000000e+00) 150 store float %28, float* %slotf 151; FNOBUILTIN: call 152 %29 = call float @logf(float 3.000000e+00) 153 store float %29, float* %slotf 154; FNOBUILTIN: call 155 %30 = call float @log10f(float 3.000000e+00) 156 store float %30, float* %slotf 157; FNOBUILTIN: call 158 %31 = call float @powf(float 3.000000e+00, float 4.000000e+00) 159 store float %31, float* %slotf 160; FNOBUILTIN: call 161 %roundf_val = call float @roundf(float 3.000000e+00) 162 store float %roundf_val, float* %slotf 163; FNOBUILTIN: call 164 %32 = call float @sinf(float 3.000000e+00) 165 store float %32, float* %slotf 166; FNOBUILTIN: call 167 %33 = call float @sinhf(float 3.000000e+00) 168 store float %33, float* %slotf 169; FNOBUILTIN: call 170 %34 = call float @sqrtf(float 3.000000e+00) 171 store float %34, float* %slotf 172; FNOBUILTIN: call 173 %35 = call float @tanf(float 3.000000e+00) 174 store float %35, float* %slotf 175; FNOBUILTIN: call 176 %36 = call float @tanhf(float 3.000000e+00) 177 store float %36, float* %slotf 178 179; FNOBUILTIN: ret 180 181 ; PR9315 182 %E = call double @exp2(double 4.0) 183 %d = fadd double %c, %E 184 ret double %d 185} 186 187define double @test_intrinsic_pow() nounwind uwtable ssp { 188entry: 189; CHECK-LABEL: @test_intrinsic_pow( 190; CHECK-NOT: call 191; CHECK: ret 192 %0 = call double @llvm.pow.f64(double 1.500000e+00, double 3.000000e+00) 193 ret double %0 194} 195 196define float @test_intrinsic_pow_f32_overflow() nounwind uwtable ssp { 197entry: 198; CHECK-LABEL: @test_intrinsic_pow_f32_overflow( 199; CHECK-NOT: call 200; CHECK: ret float 0x7FF0000000000000 201 %0 = call float @llvm.pow.f32(float 40.0, float 50.0) 202 ret float %0 203} 204 205declare double @llvm.pow.f64(double, double) nounwind readonly 206declare float @llvm.pow.f32(float, float) nounwind readonly 207