1 ; RUN: opt -S -instcombine < %s | FileCheck %s
3 define float @test1(float %x) nounwind readnone ssp {
10 %conv = fpext float %x to double ; <double> [#uses=1]
11 %call = tail call double @sqrt(double %conv) readnone nounwind ; <double> [#uses=1]
12 %conv1 = fptrunc double %call to float ; <float> [#uses=1]
18 define float @test2(float %x) nounwind readnone ssp {
20 ; CHECK-LABEL: @test2(
25 %conv = fpext float %x to double ; <double> [#uses=1]
26 %call = tail call double @sqrt(double %conv) nounwind ; <double> [#uses=1]
27 %conv1 = fptrunc double %call to float ; <float> [#uses=1]
33 ; Can't fold (fptrunc (sqrt (fpext x))) -> (sqrtf x) since there is another
35 define float @test3(float* %v) nounwind uwtable ssp {
37 ; CHECK-LABEL: @test3(
41 %arrayidx13 = getelementptr inbounds float* %v, i64 2
42 %tmp14 = load float* %arrayidx13
43 %mul18 = fmul float %tmp14, %tmp14
44 %add19 = fadd float undef, %mul18
45 %conv = fpext float %add19 to double
46 %call34 = call double @sqrt(double %conv) readnone
47 %call36 = call i32 (double)* @foo(double %call34) nounwind
48 %conv38 = fptrunc double %call34 to float
52 declare i32 @foo(double)
54 declare double @sqrt(double) readnone