blob: 6ee7a53ae7e648724af5d84c8c37527fb3f34d90 [file] [log] [blame]
Owen Anderson3ccd8182010-07-19 08:14:26 +00001; RUN: opt -S -instcombine %s | FileCheck %s
2
Chris Lattner6e27b3e2010-09-07 20:01:38 +00003define float @test1(float %x) nounwind readnone ssp {
Owen Anderson3ccd8182010-07-19 08:14:26 +00004entry:
Chris Lattner6e27b3e2010-09-07 20:01:38 +00005; CHECK: @test1
6; CHECK-NOT: fpext
7; CHECK-NOT: sqrt(
8; CHECK: sqrtf(
9; CHECK-NOT: fptrunc
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]
13; CHECK: ret float
14 ret float %conv1
15}
16
Chris Lattner6e27b3e2010-09-07 20:01:38 +000017; PR8096
18define float @test2(float %x) nounwind readnone ssp {
19entry:
20; CHECK: @test2
Owen Anderson3ccd8182010-07-19 08:14:26 +000021; CHECK-NOT: fpext
22; CHECK-NOT: sqrt(
23; CHECK: sqrtf(
24; CHECK-NOT: fptrunc
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]
28; CHECK: ret float
29 ret float %conv1
30}
Evan Chengb94674b2011-07-13 19:08:16 +000031
32; rdar://9763193
33; Can't fold (fptrunc (sqrt (fpext x))) -> (sqrtf x) since there is another
34; use of sqrt result.
35define float @test3(float* %v) nounwind uwtable ssp {
36entry:
37; CHECK: @test3
38; CHECK: sqrt(
39; CHECK-NOT: sqrtf(
40; CHECK: fptrunc
41 %call34 = call double @sqrt(double undef) nounwind readnone
42 %call36 = call i32 (double)* @foo(double %call34) nounwind
43 %conv38 = fptrunc double %call34 to float
44 ret float %conv38
45}
46
47declare i32 @foo(double)
48
49declare double @sqrt(double) readnone