[RS4GC] Fix rematerialization of bitcast of bitcast.
[oota-llvm.git] / test / Transforms / Inline / inline-fp.ll
1 ; RUN: opt -S -inline < %s | FileCheck %s
2 ; Make sure that soft float implementations are calculated as being more expensive
3 ; to the inliner.
4
5 define i32 @test_nofp() #0 {
6 ; f_nofp() has the "use-soft-float" attribute, so it should never get inlined.
7 ; CHECK-LABEL: test_nofp
8 ; CHECK: call float @f_nofp 
9 entry:
10   %responseX = alloca i32, align 4
11   %responseY = alloca i32, align 4
12   %responseZ = alloca i32, align 4
13   %valueX = alloca i8, align 1
14   %valueY = alloca i8, align 1
15   %valueZ = alloca i8, align 1
16
17   call void @getX(i32* %responseX, i8* %valueX)
18   call void @getY(i32* %responseY, i8* %valueY)
19   call void @getZ(i32* %responseZ, i8* %valueZ)
20
21   %0 = load i32, i32* %responseX
22   %1 = load i8, i8* %valueX
23   %call = call float @f_nofp(i32 %0, i8 zeroext %1)
24   %2 = load i32, i32* %responseZ
25   %3 = load i8, i8* %valueZ
26   %call2 = call float @f_nofp(i32 %2, i8 zeroext %3)
27   %call3 = call float @fabsf(float %call)
28   %cmp = fcmp ogt float %call3, 0x3FC1EB8520000000
29   br i1 %cmp, label %if.end12, label %if.else
30
31 if.else:                                          ; preds = %entry
32   %4 = load i32, i32* %responseY
33   %5 = load i8, i8* %valueY
34   %call1 = call float @f_nofp(i32 %4, i8 zeroext %5)
35   %call4 = call float @fabsf(float %call1)
36   %cmp5 = fcmp ogt float %call4, 0x3FC1EB8520000000
37   br i1 %cmp5, label %if.end12, label %if.else7
38
39 if.else7:                                         ; preds = %if.else
40   %call8 = call float @fabsf(float %call2)
41   %cmp9 = fcmp ogt float %call8, 0x3FC1EB8520000000
42   br i1 %cmp9, label %if.then10, label %if.end12
43
44 if.then10:                                        ; preds = %if.else7
45   br label %if.end12
46
47 if.end12:                                         ; preds = %if.else, %entry, %if.then10, %if.else7
48   %success.0 = phi i32 [ 0, %if.then10 ], [ 1, %if.else7 ], [ 0, %entry ], [ 0, %if.else ]
49   ret i32 %success.0
50 }
51
52 define i32 @test_hasfp() #0 {
53 ; f_hasfp()  does not have the "use-soft-float" attribute, so it should get inlined.
54 ; CHECK-LABEL: test_hasfp
55 ; CHECK-NOT: call float @f_hasfp 
56 entry:
57   %responseX = alloca i32, align 4
58   %responseY = alloca i32, align 4
59   %responseZ = alloca i32, align 4
60   %valueX = alloca i8, align 1
61   %valueY = alloca i8, align 1
62   %valueZ = alloca i8, align 1
63
64   call void @getX(i32* %responseX, i8* %valueX)
65   call void @getY(i32* %responseY, i8* %valueY)
66   call void @getZ(i32* %responseZ, i8* %valueZ)
67
68   %0 = load i32, i32* %responseX
69   %1 = load i8, i8* %valueX
70   %call = call float @f_hasfp(i32 %0, i8 zeroext %1)
71   %2 = load i32, i32* %responseZ
72   %3 = load i8, i8* %valueZ
73   %call2 = call float @f_hasfp(i32 %2, i8 zeroext %3)
74   %call3 = call float @fabsf(float %call)
75   %cmp = fcmp ogt float %call3, 0x3FC1EB8520000000
76   br i1 %cmp, label %if.end12, label %if.else
77
78 if.else:                                          ; preds = %entry
79   %4 = load i32, i32* %responseY
80   %5 = load i8, i8* %valueY
81   %call1 = call float @f_hasfp(i32 %4, i8 zeroext %5)
82   %call4 = call float @fabsf(float %call1)
83   %cmp5 = fcmp ogt float %call4, 0x3FC1EB8520000000
84   br i1 %cmp5, label %if.end12, label %if.else7
85
86 if.else7:                                         ; preds = %if.else
87   %call8 = call float @fabsf(float %call2)
88   %cmp9 = fcmp ogt float %call8, 0x3FC1EB8520000000
89   br i1 %cmp9, label %if.then10, label %if.end12
90
91 if.then10:                                        ; preds = %if.else7
92   br label %if.end12
93
94 if.end12:                                         ; preds = %if.else, %entry, %if.then10, %if.else7
95   %success.0 = phi i32 [ 0, %if.then10 ], [ 1, %if.else7 ], [ 0, %entry ], [ 0, %if.else ]
96   ret i32 %success.0
97 }
98
99 declare void @getX(i32*, i8*) #0
100
101 declare void @getY(i32*, i8*) #0
102
103 declare void @getZ(i32*, i8*) #0
104
105 define internal float @f_hasfp(i32 %response, i8 zeroext %value1) #0 {
106 entry:
107   %conv = zext i8 %value1 to i32
108   %sub = add nsw i32 %conv, -1
109   %conv1 = sitofp i32 %sub to float
110   %0 = tail call float @llvm.pow.f32(float 0x3FF028F5C0000000, float %conv1)
111   %mul = fmul float %0, 2.620000e+03
112   %conv2 = sitofp i32 %response to float
113   %sub3 = fsub float %conv2, %mul
114   %div = fdiv float %sub3, %mul
115   ret float %div
116 }
117
118 define internal float @f_nofp(i32 %response, i8 zeroext %value1) #1 {
119 entry:
120   %conv = zext i8 %value1 to i32
121   %sub = add nsw i32 %conv, -1
122   %conv1 = sitofp i32 %sub to float
123   %0 = tail call float @llvm.pow.f32(float 0x3FF028F5C0000000, float %conv1)
124   %mul = fmul float %0, 2.620000e+03
125   %conv2 = sitofp i32 %response to float
126   %sub3 = fsub float %conv2, %mul
127   %div = fdiv float %sub3, %mul
128   ret float %div
129 }
130
131 declare float @fabsf(float) optsize minsize
132
133 declare float @llvm.pow.f32(float, float) optsize minsize
134
135 attributes #0 = { minsize optsize }
136 attributes #1 = { minsize optsize "use-soft-float"="true" }