blob: be3dd2a93fd6bd28342c57ec74e2b17639bb5278 [file] [log] [blame]
Eric Christophercee313d2019-04-17 04:52:47 +00001; 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,+fp-only-sp -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
16; FULLFP-DAG: single inlined into test_single with (cost=0, threshold=75)
17; FULLFP-DAG: single inlined into test_single with (cost=-15000, threshold=75)
18; FULLFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15, threshold=75)
19; FULLFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15015, threshold=75)
20; FULLFP-DAG: double inlined into test_double with (cost=0, threshold=75)
21; FULLFP-DAG: double inlined into test_double with (cost=-15000, threshold=75)
22; FULLFP-DAG: single_force_soft not inlined into test_single_force_soft because too costly to inline (cost=125, threshold=75)
23; FULLFP-DAG: single_force_soft not inlined into test_single_force_soft because too costly to inline (cost=125, threshold=75)
24
25; SINGLEFP-DAG: single inlined into test_single with (cost=0, threshold=75)
26; SINGLEFP-DAG: single inlined into test_single with (cost=-15000, threshold=75)
27; SINGLEFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15, threshold=75)
28; SINGLEFP-DAG: single_cheap inlined into test_single_cheap with (cost=-15015, threshold=75)
29; SINGLEFP-DAG: double not inlined into test_double because too costly to inline (cost=125, threshold=75)
30; SINGLEFP-DAG: double not inlined into test_double because too costly to inline (cost=125, threshold=75)
31; SINGLEFP-DAG: single_force_soft not inlined into test_single_force_soft because too costly to inline (cost=125, threshold=75)
32; SINGLEFP-DAG: single_force_soft not inlined into test_single_force_soft because too costly to inline (cost=125, threshold=75)
33
34define i32 @test_single(i32 %a, i8 %b, i32 %c, i8 %d) #0 {
35 %call = call float @single(i32 %a, i8 zeroext %b)
36 %call2 = call float @single(i32 %c, i8 zeroext %d)
37 ret i32 0
38}
39
40define i32 @test_single_cheap(i32 %a, i8 %b, i32 %c, i8 %d) #0 {
41 %call = call float @single_cheap(i32 %a, i8 zeroext %b)
42 %call2 = call float @single_cheap(i32 %c, i8 zeroext %d)
43 ret i32 0
44}
45
46define i32 @test_double(i32 %a, i8 %b, i32 %c, i8 %d) #0 {
47 %call = call double @double(i32 %a, i8 zeroext %b)
48 %call2 = call double @double(i32 %c, i8 zeroext %d)
49 ret i32 0
50}
51
52define i32 @test_single_force_soft(i32 %a, i8 %b, i32 %c, i8 %d) #1 {
53 %call = call float @single_force_soft(i32 %a, i8 zeroext %b) #1
54 %call2 = call float @single_force_soft(i32 %c, i8 zeroext %d) #1
55 ret i32 0
56}
57
58define internal float @single(i32 %response, i8 zeroext %value1) #0 {
59entry:
60 %conv = zext i8 %value1 to i32
61 %sub = add nsw i32 %conv, -1
62 %conv1 = sitofp i32 %sub to float
63 %0 = tail call float @llvm.pow.f32(float 0x3FF028F5C0000000, float %conv1)
64 %mul = fmul float %0, 2.620000e+03
65 %conv2 = sitofp i32 %response to float
66 %sub3 = fsub float %conv2, %mul
67 %div = fdiv float %sub3, %mul
68 ret float %div
69}
70
71define internal float @single_cheap(i32 %response, i8 zeroext %value1) #0 {
72entry:
73 %conv = zext i8 %value1 to i32
74 %sub = add nsw i32 %conv, -1
75 %conv1 = bitcast i32 %sub to float
76 %conv2 = bitcast i32 %response to float
77 %0 = tail call float @llvm.pow.f32(float %conv2, float %conv1)
78 %1 = tail call float @llvm.pow.f32(float %0, float %0)
79 %2 = tail call float @llvm.pow.f32(float %1, float %1)
80 ret float %2
81}
82
83define internal double @double(i32 %response, i8 zeroext %value1) #0 {
84entry:
85 %conv = zext i8 %value1 to i32
86 %sub = add nsw i32 %conv, -1
87 %conv1 = sitofp i32 %sub to double
88 %0 = tail call double @llvm.pow.f64(double 0x3FF028F5C0000000, double %conv1)
89 %mul = fmul double %0, 2.620000e+03
90 %conv2 = sitofp i32 %response to double
91 %sub3 = fsub double %conv2, %mul
92 %div = fdiv double %sub3, %mul
93 ret double %div
94}
95
96define internal float @single_force_soft(i32 %response, i8 zeroext %value1) #1 {
97entry:
98 %conv = zext i8 %value1 to i32
99 %sub = add nsw i32 %conv, -1
100 %conv1 = sitofp i32 %sub to float
101 %0 = tail call float @llvm.pow.f32(float 0x3FF028F5C0000000, float %conv1)
102 %mul = fmul float %0, 2.620000e+03
103 %conv2 = sitofp i32 %response to float
104 %sub3 = fsub float %conv2, %mul
105 %div = fdiv float %sub3, %mul
106 ret float %div
107}
108
109declare float @llvm.pow.f32(float, float) optsize minsize
110declare double @llvm.pow.f64(double, double) optsize minsize
111
112attributes #0 = { optsize }
113attributes #1 = { optsize "use-soft-float"="true" "target-features"="+soft-float" }