1 ; RUN: opt -passes=inline %s -S | FileCheck %s
4 ; Ordinary function is inlined into strictfp function.
6 define float @inlined_01(float %a) {
8 %add = fadd float %a, %a
12 define float @host_02(float %a) #0 {
14 %0 = call float @inlined_01(float %a) #0
15 %add = call float @llvm.experimental.constrained.fadd.f32(float %0, float 2.000000e+00, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
17 ; CHECK-LABEL: @host_02
18 ; CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
19 ; CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float 2.000000e+00, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
23 ; strictfp function is inlined into another strictfp function.
25 define float @inlined_03(float %a) #0 {
27 %add = call float @llvm.experimental.constrained.fadd.f32(float %a, float %a, metadata !"round.downward", metadata !"fpexcept.maytrap") #0
31 define float @host_04(float %a) #0 {
33 %0 = call float @inlined_03(float %a) #0
34 %add = call float @llvm.experimental.constrained.fadd.f32(float %0, float 2.000000e+00, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
36 ; CHECK-LABEL: @host_04
37 ; CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float {{.*}}, metadata !"round.downward", metadata !"fpexcept.maytrap") #0
38 ; CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float 2.000000e+00, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
42 ; strictfp function is NOT inlined into ordinary function.
44 define float @inlined_05(float %a) strictfp {
46 %add = call float @llvm.experimental.constrained.fadd.f32(float %a, float %a, metadata !"round.downward", metadata !"fpexcept.maytrap") #0
50 define float @host_06(float %a) {
52 %0 = call float @inlined_05(float %a)
53 %add = fadd float %0, 2.000000e+00
55 ; CHECK-LABEL: @host_06
56 ; CHECK: call float @inlined_05(float %a)
57 ; CHECK: fadd float %0, 2.000000e+00
61 ; Calls in inlined function must get strictfp attribute.
63 declare float @func_ext(float);
65 define float @inlined_07(float %a) {
67 %0 = call float @func_ext(float %a)
68 %add = fadd float %0, %a
73 define float @host_08(float %a) #0 {
75 %0 = call float @inlined_07(float %a) #0
76 %add = call float @llvm.experimental.constrained.fadd.f32(float %0, float 2.000000e+00, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
78 ; CHECK-LABEL: @host_08
79 ; CHECK: call float @func_ext(float {{.*}}) #0
80 ; CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
81 ; CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float 2.000000e+00, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
85 ; Cloning particular instructions.
87 ; fpext has two overloaded types.
88 define double @inlined_09(float %a) {
90 %t = fpext float %a to double
94 define double @host_10(float %a) #0 {
96 %0 = call double @inlined_09(float %a) #0
97 %add = call double @llvm.experimental.constrained.fadd.f64(double %0, double 2.000000e+00, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
99 ; CHECK-LABEL: @host_10
100 ; CHECK: call double @llvm.experimental.constrained.fpext.f64.f32(float {{.*}}, metadata !"fpexcept.ignore") #0
101 ; CHECK: call double @llvm.experimental.constrained.fadd.f64(double {{.*}}, double 2.000000e+00, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
104 ; fcmp does not depend on rounding mode and has metadata argument.
105 define i1 @inlined_11(float %a, float %b) {
107 %t = fcmp oeq float %a, %b
111 define i1 @host_12(float %a, float %b) #0 {
113 %add = call float @llvm.experimental.constrained.fadd.f32(float %a, float %b, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
114 %cmp = call i1 @inlined_11(float %a, float %b) #0
116 ; CHECK-LABEL: @host_12
117 ; CHECK: call float @llvm.experimental.constrained.fadd.f32(float %a, float %b, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
118 ; CHECK: call i1 @llvm.experimental.constrained.fcmp.f32(float {{.*}}, metadata !"oeq", metadata !"fpexcept.ignore") #0
121 ; Intrinsic 'ceil' has constrained variant.
122 define float @inlined_13(float %a) {
124 %t = call float @llvm.ceil.f32(float %a)
128 define float @host_14(float %a) #0 {
130 %0 = call float @inlined_13(float %a) #0
131 %add = call float @llvm.experimental.constrained.fadd.f32(float %0, float 2.000000e+00, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
133 ; CHECK-LABEL: @host_14
134 ; CHECK: call float @llvm.experimental.constrained.ceil.f32(float %a, metadata !"fpexcept.ignore") #0
135 ; CHECK: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, float 2.000000e+00, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
138 attributes #0 = { strictfp }
140 declare float @llvm.experimental.constrained.fadd.f32(float, float, metadata, metadata)
141 declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata)
142 declare double @llvm.experimental.constrained.fpext.f64.f32(float, metadata)
143 declare i1 @llvm.experimental.constrained.fcmp.f32(float, float, metadata, metadata)
144 declare float @llvm.experimental.constrained.ceil.f32(float, metadata)
145 declare float @llvm.ceil.f32(float)