1; RUN: opt -S -inline -mtriple=arm-eabi -pass-remarks=.* -pass-remarks-missed=.* < %s 2>&1 | FileCheck %s -check-prefix=NOFP
2; RUN: opt -S -inline -mtriple=arm-eabi -mattr=+vfp2 -pass-remarks=.* -pass-remarks-missed=.* < %s 2>&1 | FileCheck %s -check-prefix=FULLFP
3; RUN: opt -S -inline -mtriple=arm-eabi -mattr=+vfp2,-fp64 -pass-remarks=.* -pass-remarks-missed=.* < %s 2>&1 | FileCheck %s -check-prefix=SINGLEFP
4; Make sure that soft float implementations are calculated as being more expensive
5; to the inliner.
6
7; NOFP-DAG: single not inlined into test_single because too costly to inline (cost=125, threshold=75)
8; NOFP-DAG: single not inlined into test_single because too costly to inline (cost=125, threshold=75)
9; NOFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15, threshold=75)
10; NOFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15015, threshold=75)
11; NOFP-DAG: double not inlined into test_double because too costly to inline (cost=125, threshold=75)
12; NOFP-DAG: double not inlined into test_double because too costly to inline (cost=125, threshold=75)
13; NOFP-DAG: single_force_soft not inlined into test_single_force_soft because too costly to inline (cost=125, threshold=75)
14; NOFP-DAG: single_force_soft not inlined into test_single_force_soft because too costly to inline (cost=125, threshold=75)
15; NOFP-DAG: single_force_soft_fneg not inlined into test_single_force_soft_fneg because too costly to inline (cost=100, threshold=75)
16; NOFP-DAG: single_force_soft_fneg not inlined into test_single_force_soft_fneg because too costly to inline (cost=100, threshold=75)
17
18; FULLFP-DAG: single inlined into test_single with (cost=0, threshold=75)
19; FULLFP-DAG: single inlined into test_single with (cost=-15000, threshold=75)
20; FULLFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15, threshold=75)
21; FULLFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15015, threshold=75)
22; FULLFP-DAG: double inlined into test_double with (cost=0, threshold=75)
23; FULLFP-DAG: double inlined into test_double with (cost=-15000, threshold=75)
24; FULLFP-DAG: single_force_soft not inlined into test_single_force_soft because too costly to inline (cost=125, threshold=75)
25; FULLFP-DAG: single_force_soft not inlined into test_single_force_soft because too costly to inline (cost=125, threshold=75)
26; FULLFP-DAG: single_force_soft_fneg not inlined into test_single_force_soft_fneg because too costly to inline (cost=100, threshold=75)
27; FULLFP-DAG: single_force_soft_fneg not inlined into test_single_force_soft_fneg because too costly to inline (cost=100, threshold=75)
28
29; SINGLEFP-DAG: single inlined into test_single with (cost=0, threshold=75)
30; SINGLEFP-DAG: single inlined into test_single with (cost=-15000, threshold=75)
31; SINGLEFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15, threshold=75)
32; SINGLEFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15015, threshold=75)
33; SINGLEFP-DAG: double not inlined into test_double because too costly to inline (cost=125, threshold=75)
34; SINGLEFP-DAG: double not inlined into test_double because too costly to inline (cost=125, threshold=75)
35; SINGLEFP-DAG: single_force_soft not inlined into test_single_force_soft because too costly to inline (cost=125, threshold=75)
36; SINGLEFP-DAG: single_force_soft not inlined into test_single_force_soft because too costly to inline (cost=125, threshold=75)
37; SINGLEFP-DAG: single_force_soft_fneg not inlined into test_single_force_soft_fneg because too costly to inline (cost=100, threshold=75)
38; SINGLEFP-DAG: single_force_soft_fneg not inlined into test_single_force_soft_fneg because too costly to inline (cost=100, threshold=75)
39
40define i32 @test_single(i32 %a, i8 %b, i32 %c, i8 %d) #0 {
41  %call = call float @single(i32 %a, i8 zeroext %b)
42  %call2 = call float @single(i32 %c, i8 zeroext %d)
43  ret i32 0
44}
45
46define i32 @test_single_cheap(i32 %a, i8 %b, i32 %c, i8 %d) #0 {
47  %call = call float @single_cheap(i32 %a, i8 zeroext %b)
48  %call2 = call float @single_cheap(i32 %c, i8 zeroext %d)
49  ret i32 0
50}
51
52define i32 @test_double(i32 %a, i8 %b, i32 %c, i8 %d) #0 {
53  %call = call double @double(i32 %a, i8 zeroext %b)
54  %call2 = call double @double(i32 %c, i8 zeroext %d)
55  ret i32 0
56}
57
58define i32 @test_single_force_soft(i32 %a, i8 %b, i32 %c, i8 %d) #1 {
59  %call = call float @single_force_soft(i32 %a, i8 zeroext %b) #1
60  %call2 = call float @single_force_soft(i32 %c, i8 zeroext %d) #1
61  ret i32 0
62}
63
64define i32 @test_single_force_soft_fneg(i32 %a, i8 %b, i32 %c, i8 %d) #1 {
65  %call = call float @single_force_soft_fneg(i32 %a, i8 zeroext %b) #1
66  %call2 = call float @single_force_soft_fneg(i32 %c, i8 zeroext %d) #1
67  ret i32 0
68}
69
70define internal float @single(i32 %response, i8 zeroext %value1) #0 {
71entry:
72  %conv = zext i8 %value1 to i32
73  %sub = add nsw i32 %conv, -1
74  %conv1 = sitofp i32 %sub to float
75  %0 = tail call float @llvm.pow.f32(float 0x3FF028F5C0000000, float %conv1)
76  %mul = fmul float %0, 2.620000e+03
77  %conv2 = sitofp i32 %response to float
78  %sub3 = fsub float %conv2, %mul
79  %div = fdiv float %sub3, %mul
80  ret float %div
81}
82
83define internal float @single_cheap(i32 %response, i8 zeroext %value1) #0 {
84entry:
85  %conv = zext i8 %value1 to i32
86  %sub = add nsw i32 %conv, -1
87  %conv1 = bitcast i32 %sub to float
88  %conv2 = bitcast i32 %response to float
89  %0 = tail call float @llvm.pow.f32(float %conv2, float %conv1)
90  %1 = tail call float @llvm.pow.f32(float %0, float %0)
91  %2 = tail call float @llvm.pow.f32(float %1, float %1)
92  ret float %2
93}
94
95define internal double @double(i32 %response, i8 zeroext %value1) #0 {
96entry:
97  %conv = zext i8 %value1 to i32
98  %sub = add nsw i32 %conv, -1
99  %conv1 = sitofp i32 %sub to double
100  %0 = tail call double @llvm.pow.f64(double 0x3FF028F5C0000000, double %conv1)
101  %mul = fmul double %0, 2.620000e+03
102  %conv2 = sitofp i32 %response to double
103  %sub3 = fsub double %conv2, %mul
104  %div = fdiv double %sub3, %mul
105  ret double %div
106}
107
108define internal float @single_force_soft(i32 %response, i8 zeroext %value1) #1 {
109entry:
110  %conv = zext i8 %value1 to i32
111  %sub = add nsw i32 %conv, -1
112  %conv1 = sitofp i32 %sub to float
113  %0 = tail call float @llvm.pow.f32(float 0x3FF028F5C0000000, float %conv1)
114  %mul = fmul float %0, 2.620000e+03
115  %conv2 = sitofp i32 %response to float
116  %sub3 = fsub float %conv2, %mul
117  %div = fdiv float %sub3, %mul
118  ret float %div
119}
120
121define internal float @single_force_soft_fneg(i32 %response, i8 zeroext %value1) #1 {
122entry:
123  %conv = zext i8 %value1 to i32
124  %sub = add nsw i32 %conv, -1
125  %conv1 = sitofp i32 %sub to float
126  %0 = tail call float @llvm.pow.f32(float 0x3FF028F5C0000000, float %conv1)
127  %mul = fsub float -0.0, %0
128  %conv2 = sitofp i32 %response to float
129  %sub3 = fsub float %conv2, %mul
130  %div = fdiv float %sub3, %mul
131  ret float %div
132}
133
134declare float @llvm.pow.f32(float, float) optsize minsize
135declare double @llvm.pow.f64(double, double) optsize minsize
136
137attributes #0 = { optsize }
138attributes #1 = { optsize "use-soft-float"="true" "target-features"="+soft-float" }
139