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