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