1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -instcombine < %s | FileCheck %s
4 define float @test1(float %x) nounwind readnone ssp {
6 ; CHECK-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[X:%.*]]) #3
7 ; CHECK-NEXT: ret float [[SQRTF]]
9 %conv = fpext float %x to double
10 %call = tail call double @sqrt(double %conv) readnone nounwind
11 %conv1 = fptrunc double %call to float
17 define float @test2(float %x) nounwind readnone ssp {
18 ; CHECK-LABEL: @test2(
19 ; CHECK-NEXT: [[SQRTF:%.*]] = call float @sqrtf(float [[X:%.*]]) #3
20 ; CHECK-NEXT: ret float [[SQRTF]]
22 %conv = fpext float %x to double
23 %call = tail call double @sqrt(double %conv) nounwind
24 %conv1 = fptrunc double %call to float
29 ; Can't fold (fptrunc (sqrt (fpext x))) -> (sqrtf x) since there is another
32 define float @test3(float* %v) nounwind uwtable ssp {
33 ; CHECK-LABEL: @test3(
34 ; CHECK-NEXT: [[CALL34:%.*]] = call double @sqrt(double 0x7FF8000000000000) #3
35 ; CHECK-NEXT: [[CALL36:%.*]] = call i32 @foo(double [[CALL34]]) #4
36 ; CHECK-NEXT: [[CONV38:%.*]] = fptrunc double [[CALL34]] to float
37 ; CHECK-NEXT: ret float [[CONV38]]
39 %arrayidx13 = getelementptr inbounds float, float* %v, i64 2
40 %tmp14 = load float, float* %arrayidx13
41 %mul18 = fmul float %tmp14, %tmp14
42 %add19 = fadd float undef, %mul18
43 %conv = fpext float %add19 to double
44 %call34 = call double @sqrt(double %conv) readnone
45 %call36 = call i32 (double) @foo(double %call34) nounwind
46 %conv38 = fptrunc double %call34 to float
50 declare i32 @foo(double)
51 declare double @sqrt(double) readnone