1 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
3 ! CHECK-LABEL: c.func @_QPnearest_test1
4 ! CHECK: %[[V_0:[0-9]+]] = fir.dummy_scope : !fir.dscope
5 ! CHECK: %[[V_1:[0-9]+]] = fir.alloca f16 {bindc_name = "res", uniq_name = "_QFnearest_test1Eres"}
6 ! CHECK: %[[V_2:[0-9]+]] = fir.declare %[[V_1]] {uniq_name = "_QFnearest_test1Eres"} : (!fir.ref<f16>) -> !fir.ref<f16>
7 ! CHECK: %[[V_3:[0-9]+]] = fir.declare %arg1 dummy_scope %[[V_0]] {uniq_name = "_QFnearest_test1Es"} : (!fir.ref<f16>, !fir.dscope) -> !fir.ref<f16>
8 ! CHECK: %[[V_4:[0-9]+]] = fir.declare %arg0 dummy_scope %[[V_0]] {uniq_name = "_QFnearest_test1Ex"} : (!fir.ref<f16>, !fir.dscope) -> !fir.ref<f16>
9 ! CHECK: %[[V_5:[0-9]+]] = fir.load %[[V_4]] : !fir.ref<f16>
10 ! CHECK: %[[V_6:[0-9]+]] = fir.load %[[V_3]] : !fir.ref<f16>
11 ! CHECK: %[[V_7:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_5]]) <{bit = 3 : i32}> : (f16) -> i1
12 ! CHECK: %[[V_8:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_6]]) <{bit = 96 : i32}> : (f16) -> i1
13 ! CHECK: fir.if %[[V_8]] {
14 ! CHECK: fir.call @_FortranAReportFatalUserError
16 ! CHECK: %[[V_9:[0-9]+]] = arith.bitcast %[[V_6]] : f16 to i16
17 ! CHECK: %[[V_10:[0-9]+]] = arith.shrui %[[V_9]], %c15{{.*}} : i16
18 ! CHECK: %[[V_11:[0-9]+]] = arith.cmpi ne, %[[V_10]], %c1{{.*}} : i16
19 ! CHECK: %[[V_12:[0-9]+]] = arith.bitcast %[[V_5]] : f16 to i16
20 ! CHECK: %[[V_13:[0-9]+]] = arith.shrui %[[V_12]], %c15{{.*}} : i16
21 ! CHECK: %[[V_14:[0-9]+]] = fir.convert %[[V_13]] : (i16) -> i1
22 ! CHECK: %[[V_15:[0-9]+]] = arith.cmpi ne, %[[V_11]], %[[V_14]] : i1
23 ! CHECK: %[[V_16:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_5]]) <{bit = 516 : i32}> : (f16) -> i1
24 ! CHECK: %[[V_17:[0-9]+]] = arith.andi %[[V_16]], %[[V_15]] : i1
25 ! CHECK: %[[V_18:[0-9]+]] = arith.ori %[[V_7]], %[[V_17]] : i1
26 ! CHECK: %[[V_19:[0-9]+]] = fir.if %[[V_18]] -> (f16) {
27 ! CHECK: fir.result %[[V_5]] : f16
29 ! CHECK: %[[V_20:[0-9]+]] = arith.cmpf oeq, %[[V_5]], %cst{{[_0-9]*}} fastmath<contract> : f16
30 ! CHECK: %[[V_21:[0-9]+]] = fir.if %[[V_20]] -> (f16) {
31 ! CHECK: %[[V_22:[0-9]+]] = arith.select %[[V_11]], %cst{{[_0-9]*}}, %cst{{[_0-9]*}} : f16
32 ! CHECK: %[[V_23:[0-9]+]] = fir.call @_FortranAMapException(%c48{{.*}}) fastmath<contract> : (i32) -> i32
33 ! CHECK: fir.call @feraiseexcept(%[[V_23]]) fastmath<contract> : (i32) -> i32
34 ! CHECK: fir.result %[[V_22]] : f16
36 ! CHECK-DAG: %[[V_22:[0-9]+]] = arith.subi %[[V_12]], %c1{{.*}} : i16
37 ! CHECK-DAG: %[[V_23:[0-9]+]] = arith.addi %[[V_12]], %c1{{.*}} : i16
38 ! CHECK: %[[V_24:[0-9]+]] = arith.select %[[V_15]], %[[V_23]], %[[V_22]] : i16
39 ! CHECK: %[[V_25:[0-9]+]] = arith.bitcast %[[V_24]] : i16 to f16
40 ! CHECK: %[[V_26:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_25]]) <{bit = 516 : i32}> : (f16) -> i1
41 ! CHECK: fir.if %[[V_26]] {
42 ! CHECK: %[[V_28:[0-9]+]] = fir.call @_FortranAMapException(%c40{{.*}}) fastmath<contract> : (i32) -> i32
43 ! CHECK: fir.call @feraiseexcept(%[[V_28]]) fastmath<contract> : (i32) -> i32
45 ! CHECK: %[[V_27:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_25]]) <{bit = 144 : i32}> : (f16) -> i1
46 ! CHECK: fir.if %[[V_27]] {
47 ! CHECK: %[[V_28:[0-9]+]] = fir.call @_FortranAMapException(%c48{{.*}}) fastmath<contract> : (i32) -> i32
48 ! CHECK: fir.call @feraiseexcept(%[[V_28]]) fastmath<contract> : (i32) -> i32
50 ! CHECK: fir.result %[[V_25]] : f16
52 ! CHECK: fir.result %[[V_21]] : f16
54 ! CHECK: fir.store %[[V_19]] to %[[V_2]] : !fir.ref<f16>
57 subroutine nearest_test1(x
, s
)
58 real(kind
=2) :: x
, s
, res
62 ! CHECK-LABEL: c.func @_QPnearest_test2
63 ! CHECK: %[[V_0:[0-9]+]] = fir.dummy_scope : !fir.dscope
64 ! CHECK: %[[V_1:[0-9]+]] = fir.alloca bf16 {bindc_name = "res", uniq_name = "_QFnearest_test2Eres"}
65 ! CHECK: %[[V_2:[0-9]+]] = fir.declare %[[V_1]] {uniq_name = "_QFnearest_test2Eres"} : (!fir.ref<bf16>) -> !fir.ref<bf16>
66 ! CHECK: %[[V_3:[0-9]+]] = fir.declare %arg1 dummy_scope %[[V_0]] {uniq_name = "_QFnearest_test2Es"} : (!fir.ref<bf16>, !fir.dscope) -> !fir.ref<bf16>
67 ! CHECK: %[[V_4:[0-9]+]] = fir.declare %arg0 dummy_scope %[[V_0]] {uniq_name = "_QFnearest_test2Ex"} : (!fir.ref<bf16>, !fir.dscope) -> !fir.ref<bf16>
68 ! CHECK: %[[V_5:[0-9]+]] = fir.load %[[V_4]] : !fir.ref<bf16>
69 ! CHECK: %[[V_6:[0-9]+]] = fir.load %[[V_3]] : !fir.ref<bf16>
70 ! CHECK: %[[V_7:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_5]]) <{bit = 3 : i32}> : (bf16) -> i1
71 ! CHECK: %[[V_8:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_6]]) <{bit = 96 : i32}> : (bf16) -> i1
72 ! CHECK: fir.if %[[V_8]] {
73 ! CHECK: fir.call @_FortranAReportFatalUserError
75 ! CHECK: %[[V_9:[0-9]+]] = fir.convert %[[V_6]] : (bf16) -> f32
76 ! CHECK: %[[V_10:[0-9]+]] = arith.bitcast %[[V_9]] : f32 to i32
77 ! CHECK: %[[V_11:[0-9]+]] = arith.shrui %[[V_10]], %c31{{.*}} : i32
78 ! CHECK: %[[V_12:[0-9]+]] = fir.convert %[[V_11]] : (i32) -> i16
79 ! CHECK: %[[V_13:[0-9]+]] = arith.cmpi ne, %[[V_12]], %c1{{.*}} : i16
80 ! CHECK: %[[V_14:[0-9]+]] = fir.convert %[[V_5]] : (bf16) -> f32
81 ! CHECK: %[[V_15:[0-9]+]] = arith.bitcast %[[V_14]] : f32 to i32
82 ! CHECK: %[[V_16:[0-9]+]] = arith.shrui %[[V_15]], %c31{{.*}} : i32
83 ! CHECK: %[[V_17:[0-9]+]] = fir.convert %[[V_16]] : (i32) -> i1
84 ! CHECK: %[[V_18:[0-9]+]] = arith.cmpi ne, %[[V_13]], %[[V_17]] : i1
85 ! CHECK: %[[V_19:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_5]]) <{bit = 516 : i32}> : (bf16) -> i1
86 ! CHECK: %[[V_20:[0-9]+]] = arith.andi %[[V_19]], %[[V_18]] : i1
87 ! CHECK: %[[V_21:[0-9]+]] = arith.ori %[[V_7]], %[[V_20]] : i1
88 ! CHECK: %[[V_22:[0-9]+]] = fir.if %[[V_21]] -> (bf16) {
89 ! CHECK: fir.result %[[V_5]] : bf16
91 ! CHECK: %[[V_23:[0-9]+]] = arith.cmpf oeq, %[[V_5]], %cst{{[_0-9]*}} fastmath<contract> : bf16
92 ! CHECK: %[[V_24:[0-9]+]] = fir.if %[[V_23]] -> (bf16) {
93 ! CHECK: %[[V_25:[0-9]+]] = arith.select %[[V_13]], %cst{{[_0-9]*}}, %cst{{[_0-9]*}} : bf16
94 ! CHECK: %[[V_26:[0-9]+]] = fir.call @_FortranAMapException(%c48{{.*}}) fastmath<contract> : (i32) -> i32
95 ! CHECK: fir.call @feraiseexcept(%[[V_26]]) fastmath<contract> : (i32) -> i32
96 ! CHECK: fir.result %[[V_25]] : bf16
98 ! CHECK: %[[V_25:[0-9]+]] = arith.bitcast %[[V_5]] : bf16 to i16
99 ! CHECK-DAG: %[[V_26:[0-9]+]] = arith.subi %[[V_25]], %c1{{.*}} : i16
100 ! CHECK-DAG: %[[V_27:[0-9]+]] = arith.addi %[[V_25]], %c1{{.*}} : i16
101 ! CHECK: %[[V_28:[0-9]+]] = arith.select %[[V_18]], %[[V_27]], %[[V_26]] : i16
102 ! CHECK: %[[V_29:[0-9]+]] = arith.bitcast %[[V_28]] : i16 to bf16
103 ! CHECK: %[[V_30:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_29]]) <{bit = 516 : i32}> : (bf16) -> i1
104 ! CHECK: fir.if %[[V_30]] {
105 ! CHECK: %[[V_32:[0-9]+]] = fir.call @_FortranAMapException(%c40{{.*}}) fastmath<contract> : (i32) -> i32
106 ! CHECK: fir.call @feraiseexcept(%[[V_32]]) fastmath<contract> : (i32) -> i32
108 ! CHECK: %[[V_31:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_29]]) <{bit = 144 : i32}> : (bf16) -> i1
109 ! CHECK: fir.if %[[V_31]] {
110 ! CHECK: %[[V_32:[0-9]+]] = fir.call @_FortranAMapException(%c48{{.*}}) fastmath<contract> : (i32) -> i32
111 ! CHECK: fir.call @feraiseexcept(%[[V_32]]) fastmath<contract> : (i32) -> i32
113 ! CHECK: fir.result %[[V_29]] : bf16
115 ! CHECK: fir.result %[[V_24]] : bf16
117 ! CHECK: fir.store %[[V_22]] to %[[V_2]] : !fir.ref<bf16>
120 subroutine nearest_test2(x
, s
)
121 real(kind
=3) :: x
, s
, res
125 ! CHECK-LABEL: c.func @_QPnearest_test3
126 ! CHECK: %[[V_0:[0-9]+]] = fir.dummy_scope : !fir.dscope
127 ! CHECK: %[[V_1:[0-9]+]] = fir.alloca f32 {bindc_name = "res", uniq_name = "_QFnearest_test3Eres"}
128 ! CHECK: %[[V_2:[0-9]+]] = fir.declare %[[V_1]] {uniq_name = "_QFnearest_test3Eres"} : (!fir.ref<f32>) -> !fir.ref<f32>
129 ! CHECK: %[[V_3:[0-9]+]] = fir.declare %arg1 dummy_scope %[[V_0]] {uniq_name = "_QFnearest_test3Es"} : (!fir.ref<f32>, !fir.dscope) -> !fir.ref<f32>
130 ! CHECK: %[[V_4:[0-9]+]] = fir.declare %arg0 dummy_scope %[[V_0]] {uniq_name = "_QFnearest_test3Ex"} : (!fir.ref<f32>, !fir.dscope) -> !fir.ref<f32>
131 ! CHECK: %[[V_5:[0-9]+]] = fir.load %[[V_4]] : !fir.ref<f32>
132 ! CHECK: %[[V_6:[0-9]+]] = fir.load %[[V_3]] : !fir.ref<f32>
133 ! CHECK: %[[V_7:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_5]]) <{bit = 3 : i32}> : (f32) -> i1
134 ! CHECK: %[[V_8:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_6]]) <{bit = 96 : i32}> : (f32) -> i1
135 ! CHECK: fir.if %[[V_8]] {
136 ! CHECK: fir.call @_FortranAReportFatalUserError
138 ! CHECK: %[[V_9:[0-9]+]] = arith.bitcast %[[V_6]] : f32 to i32
139 ! CHECK: %[[V_10:[0-9]+]] = arith.shrui %[[V_9]], %c31{{.*}} : i32
140 ! CHECK: %[[V_11:[0-9]+]] = arith.cmpi ne, %[[V_10]], %c1{{.*}} : i32
141 ! CHECK: %[[V_12:[0-9]+]] = arith.bitcast %[[V_5]] : f32 to i32
142 ! CHECK: %[[V_13:[0-9]+]] = arith.shrui %[[V_12]], %c31{{.*}} : i32
143 ! CHECK: %[[V_14:[0-9]+]] = fir.convert %[[V_13]] : (i32) -> i1
144 ! CHECK: %[[V_15:[0-9]+]] = arith.cmpi ne, %[[V_11]], %[[V_14]] : i1
145 ! CHECK: %[[V_16:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_5]]) <{bit = 516 : i32}> : (f32) -> i1
146 ! CHECK: %[[V_17:[0-9]+]] = arith.andi %[[V_16]], %[[V_15]] : i1
147 ! CHECK: %[[V_18:[0-9]+]] = arith.ori %[[V_7]], %[[V_17]] : i1
148 ! CHECK: %[[V_19:[0-9]+]] = fir.if %[[V_18]] -> (f32) {
149 ! CHECK: fir.result %[[V_5]] : f32
151 ! CHECK: %[[V_20:[0-9]+]] = arith.cmpf oeq, %[[V_5]], %cst{{[_0-9]*}} fastmath<contract> : f32
152 ! CHECK: %[[V_21:[0-9]+]] = fir.if %[[V_20]] -> (f32) {
153 ! CHECK: %[[V_22:[0-9]+]] = arith.select %[[V_11]], %cst{{[_0-9]*}}, %cst{{[_0-9]*}} : f32
154 ! CHECK: %[[V_23:[0-9]+]] = fir.call @_FortranAMapException(%c48{{.*}}) fastmath<contract> : (i32) -> i32
155 ! CHECK: fir.call @feraiseexcept(%[[V_23]]) fastmath<contract> : (i32) -> i32
156 ! CHECK: fir.result %[[V_22]] : f32
158 ! CHECK-DAG: %[[V_22:[0-9]+]] = arith.subi %[[V_12]], %c1{{.*}} : i32
159 ! CHECK-DAG: %[[V_23:[0-9]+]] = arith.addi %[[V_12]], %c1{{.*}} : i32
160 ! CHECK: %[[V_24:[0-9]+]] = arith.select %[[V_15]], %[[V_23]], %[[V_22]] : i32
161 ! CHECK: %[[V_25:[0-9]+]] = arith.bitcast %[[V_24]] : i32 to f32
162 ! CHECK: %[[V_26:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_25]]) <{bit = 516 : i32}> : (f32) -> i1
163 ! CHECK: fir.if %[[V_26]] {
164 ! CHECK: %[[V_28:[0-9]+]] = fir.call @_FortranAMapException(%c40{{.*}}) fastmath<contract> : (i32) -> i32
165 ! CHECK: fir.call @feraiseexcept(%[[V_28]]) fastmath<contract> : (i32) -> i32
167 ! CHECK: %[[V_27:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_25]]) <{bit = 144 : i32}> : (f32) -> i1
168 ! CHECK: fir.if %[[V_27]] {
169 ! CHECK: %[[V_28:[0-9]+]] = fir.call @_FortranAMapException(%c48{{.*}}) fastmath<contract> : (i32) -> i32
170 ! CHECK: fir.call @feraiseexcept(%[[V_28]]) fastmath<contract> : (i32) -> i32
172 ! CHECK: fir.result %[[V_25]] : f32
174 ! CHECK: fir.result %[[V_21]] : f32
176 ! CHECK: fir.store %[[V_19]] to %[[V_2]] : !fir.ref<f32>
179 subroutine nearest_test3(x
, s
)
184 ! CHECK-LABEL: c.func @_QPnearest_test4
185 ! CHECK: %[[V_0:[0-9]+]] = fir.dummy_scope : !fir.dscope
186 ! CHECK: %[[V_1:[0-9]+]] = fir.alloca f64 {bindc_name = "res", uniq_name = "_QFnearest_test4Eres"}
187 ! CHECK: %[[V_2:[0-9]+]] = fir.declare %[[V_1]] {uniq_name = "_QFnearest_test4Eres"} : (!fir.ref<f64>) -> !fir.ref<f64>
188 ! CHECK: %[[V_3:[0-9]+]] = fir.declare %arg1 dummy_scope %[[V_0]] {uniq_name = "_QFnearest_test4Es"} : (!fir.ref<f64>, !fir.dscope) -> !fir.ref<f64>
189 ! CHECK: %[[V_4:[0-9]+]] = fir.declare %arg0 dummy_scope %[[V_0]] {uniq_name = "_QFnearest_test4Ex"} : (!fir.ref<f64>, !fir.dscope) -> !fir.ref<f64>
190 ! CHECK: %[[V_5:[0-9]+]] = fir.load %[[V_4]] : !fir.ref<f64>
191 ! CHECK: %[[V_6:[0-9]+]] = fir.load %[[V_3]] : !fir.ref<f64>
192 ! CHECK: %[[V_7:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_5]]) <{bit = 3 : i32}> : (f64) -> i1
193 ! CHECK: %[[V_8:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_6]]) <{bit = 96 : i32}> : (f64) -> i1
194 ! CHECK: fir.if %[[V_8]] {
195 ! CHECK: fir.call @_FortranAReportFatalUserError
197 ! CHECK: %[[V_9:[0-9]+]] = arith.bitcast %[[V_6]] : f64 to i64
198 ! CHECK: %[[V_10:[0-9]+]] = arith.shrui %[[V_9]], %c63{{.*}} : i64
199 ! CHECK: %[[V_11:[0-9]+]] = arith.cmpi ne, %[[V_10]], %c1{{.*}} : i64
200 ! CHECK: %[[V_12:[0-9]+]] = arith.bitcast %[[V_5]] : f64 to i64
201 ! CHECK: %[[V_13:[0-9]+]] = arith.shrui %[[V_12]], %c63{{.*}} : i64
202 ! CHECK: %[[V_14:[0-9]+]] = fir.convert %[[V_13]] : (i64) -> i1
203 ! CHECK: %[[V_15:[0-9]+]] = arith.cmpi ne, %[[V_11]], %[[V_14]] : i1
204 ! CHECK: %[[V_16:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_5]]) <{bit = 516 : i32}> : (f64) -> i1
205 ! CHECK: %[[V_17:[0-9]+]] = arith.andi %[[V_16]], %[[V_15]] : i1
206 ! CHECK: %[[V_18:[0-9]+]] = arith.ori %[[V_7]], %[[V_17]] : i1
207 ! CHECK: %[[V_19:[0-9]+]] = fir.if %[[V_18]] -> (f64) {
208 ! CHECK: fir.result %[[V_5]] : f64
210 ! CHECK: %[[V_20:[0-9]+]] = arith.cmpf oeq, %[[V_5]], %cst{{[_0-9]*}} fastmath<contract> : f64
211 ! CHECK: %[[V_21:[0-9]+]] = fir.if %[[V_20]] -> (f64) {
212 ! CHECK: %[[V_22:[0-9]+]] = arith.select %[[V_11]], %cst{{[_0-9]*}}, %cst{{[_0-9]*}} : f64
213 ! CHECK: %[[V_23:[0-9]+]] = fir.call @_FortranAMapException(%c48{{.*}}) fastmath<contract> : (i32) -> i32
214 ! CHECK: fir.call @feraiseexcept(%[[V_23]]) fastmath<contract> : (i32) -> i32
215 ! CHECK: fir.result %[[V_22]] : f64
217 ! CHECK-DAG: %[[V_22:[0-9]+]] = arith.subi %[[V_12]], %c1{{.*}} : i64
218 ! CHECK-DAG: %[[V_23:[0-9]+]] = arith.addi %[[V_12]], %c1{{.*}} : i64
219 ! CHECK: %[[V_24:[0-9]+]] = arith.select %[[V_15]], %[[V_23]], %[[V_22]] : i64
220 ! CHECK: %[[V_25:[0-9]+]] = arith.bitcast %[[V_24]] : i64 to f64
221 ! CHECK: %[[V_26:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_25]]) <{bit = 516 : i32}> : (f64) -> i1
222 ! CHECK: fir.if %[[V_26]] {
223 ! CHECK: %[[V_28:[0-9]+]] = fir.call @_FortranAMapException(%c40{{.*}}) fastmath<contract> : (i32) -> i32
224 ! CHECK: fir.call @feraiseexcept(%[[V_28]]) fastmath<contract> : (i32) -> i32
226 ! CHECK: %[[V_27:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_25]]) <{bit = 144 : i32}> : (f64) -> i1
227 ! CHECK: fir.if %[[V_27]] {
228 ! CHECK: %[[V_28:[0-9]+]] = fir.call @_FortranAMapException(%c48{{.*}}) fastmath<contract> : (i32) -> i32
229 ! CHECK: fir.call @feraiseexcept(%[[V_28]]) fastmath<contract> : (i32) -> i32
231 ! CHECK: fir.result %[[V_25]] : f64
233 ! CHECK: fir.result %[[V_21]] : f64
235 ! CHECK: fir.store %[[V_19]] to %[[V_2]] : !fir.ref<f64>
238 subroutine nearest_test4(x
, s
)
239 real(kind
=8) :: x
, s
, res
243 ! CHECK-LABEL: c.func @_QPnearest_test5
244 ! CHECK: %[[V_0:[0-9]+]] = fir.dummy_scope : !fir.dscope
245 ! CHECK: %[[V_1:[0-9]+]] = fir.alloca f80 {bindc_name = "res", uniq_name = "_QFnearest_test5Eres"}
246 ! CHECK: %[[V_2:[0-9]+]] = fir.declare %[[V_1]] {uniq_name = "_QFnearest_test5Eres"} : (!fir.ref<f80>) -> !fir.ref<f80>
247 ! CHECK: %[[V_3:[0-9]+]] = fir.declare %arg1 dummy_scope %[[V_0]] {uniq_name = "_QFnearest_test5Es"} : (!fir.ref<f80>, !fir.dscope) -> !fir.ref<f80>
248 ! CHECK: %[[V_4:[0-9]+]] = fir.declare %arg0 dummy_scope %[[V_0]] {uniq_name = "_QFnearest_test5Ex"} : (!fir.ref<f80>, !fir.dscope) -> !fir.ref<f80>
249 ! CHECK: %[[V_5:[0-9]+]] = fir.load %[[V_4]] : !fir.ref<f80>
250 ! CHECK: %[[V_6:[0-9]+]] = fir.load %[[V_3]] : !fir.ref<f80>
251 ! CHECK: %[[V_7:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_5]]) <{bit = 3 : i32}> : (f80) -> i1
252 ! CHECK: %[[V_8:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_6]]) <{bit = 96 : i32}> : (f80) -> i1
253 ! CHECK: fir.if %[[V_8]] {
254 ! CHECK: fir.call @_FortranAReportFatalUserError
256 ! CHECK: %[[V_9:[0-9]+]] = arith.bitcast %[[V_6]] : f80 to i80
257 ! CHECK: %[[V_10:[0-9]+]] = arith.shrui %[[V_9]], %c79{{.*}} : i80
258 ! CHECK: %[[V_11:[0-9]+]] = arith.cmpi ne, %[[V_10]], %c1{{.*}} : i80
259 ! CHECK: %[[V_12:[0-9]+]] = arith.bitcast %[[V_5]] : f80 to i80
260 ! CHECK: %[[V_13:[0-9]+]] = arith.shrui %[[V_12]], %c79{{.*}} : i80
261 ! CHECK: %[[V_14:[0-9]+]] = fir.convert %[[V_13]] : (i80) -> i1
262 ! CHECK: %[[V_15:[0-9]+]] = arith.cmpi ne, %[[V_11]], %[[V_14]] : i1
263 ! CHECK: %[[V_16:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_5]]) <{bit = 516 : i32}> : (f80) -> i1
264 ! CHECK: %[[V_17:[0-9]+]] = arith.andi %[[V_16]], %[[V_15]] : i1
265 ! CHECK: %[[V_18:[0-9]+]] = arith.ori %[[V_7]], %[[V_17]] : i1
266 ! CHECK: %[[V_19:[0-9]+]] = fir.if %[[V_18]] -> (f80) {
267 ! CHECK: fir.result %[[V_5]] : f80
269 ! CHECK: %[[V_20:[0-9]+]] = arith.cmpf oeq, %[[V_5]], %cst{{[_0-9]*}} fastmath<contract> : f80
270 ! CHECK: %[[V_21:[0-9]+]] = fir.if %[[V_20]] -> (f80) {
271 ! CHECK: %[[V_22:[0-9]+]] = arith.select %[[V_11]], %cst{{[_0-9]*}}, %cst{{[_0-9]*}} : f80
272 ! CHECK: %[[V_23:[0-9]+]] = fir.call @_FortranAMapException(%c48{{.*}}) fastmath<contract> : (i32) -> i32
273 ! CHECK: fir.call @feraiseexcept(%[[V_23]]) fastmath<contract> : (i32) -> i32
274 ! CHECK: fir.result %[[V_22]] : f80
276 ! CHECK: %[[V_22:[0-9]+]] = fir.call @_FortranANearest10(%[[V_5]], %[[V_11]]) fastmath<contract> : (f80, i1) -> f80
277 ! CHECK: fir.result %[[V_22]] : f80
279 ! CHECK: fir.result %[[V_21]] : f80
281 ! CHECK: fir.store %[[V_19]] to %[[V_2]] : !fir.ref<f80>
284 subroutine nearest_test5(x
, s
)
285 real(kind
=10) :: x
, s
, res
289 ! CHECK-LABEL: c.func @_QPnearest_test6
290 ! CHECK: %[[V_0:[0-9]+]] = fir.dummy_scope : !fir.dscope
291 ! CHECK: %[[V_1:[0-9]+]] = fir.alloca f128 {bindc_name = "res", uniq_name = "_QFnearest_test6Eres"}
292 ! CHECK: %[[V_2:[0-9]+]] = fir.declare %[[V_1]] {uniq_name = "_QFnearest_test6Eres"} : (!fir.ref<f128>) -> !fir.ref<f128>
293 ! CHECK: %[[V_3:[0-9]+]] = fir.declare %arg1 dummy_scope %[[V_0]] {uniq_name = "_QFnearest_test6Es"} : (!fir.ref<f128>, !fir.dscope) -> !fir.ref<f128>
294 ! CHECK: %[[V_4:[0-9]+]] = fir.declare %arg0 dummy_scope %[[V_0]] {uniq_name = "_QFnearest_test6Ex"} : (!fir.ref<f128>, !fir.dscope) -> !fir.ref<f128>
295 ! CHECK: %[[V_5:[0-9]+]] = fir.load %[[V_4]] : !fir.ref<f128>
296 ! CHECK: %[[V_6:[0-9]+]] = fir.load %[[V_3]] : !fir.ref<f128>
297 ! CHECK: %[[V_7:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_5]]) <{bit = 3 : i32}> : (f128) -> i1
298 ! CHECK: %[[V_8:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_6]]) <{bit = 96 : i32}> : (f128) -> i1
299 ! CHECK: fir.if %[[V_8]] {
300 ! CHECK: fir.call @_FortranAReportFatalUserError
302 ! CHECK: %[[V_9:[0-9]+]] = arith.bitcast %[[V_6]] : f128 to i128
303 ! CHECK: %[[V_10:[0-9]+]] = arith.shrui %[[V_9]], %c127{{.*}} : i128
304 ! CHECK: %[[V_11:[0-9]+]] = arith.cmpi ne, %[[V_10]], %c1{{.*}} : i128
305 ! CHECK: %[[V_12:[0-9]+]] = arith.bitcast %[[V_5]] : f128 to i128
306 ! CHECK: %[[V_13:[0-9]+]] = arith.shrui %[[V_12]], %c127{{.*}} : i128
307 ! CHECK: %[[V_14:[0-9]+]] = fir.convert %[[V_13]] : (i128) -> i1
308 ! CHECK: %[[V_15:[0-9]+]] = arith.cmpi ne, %[[V_11]], %[[V_14]] : i1
309 ! CHECK: %[[V_16:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_5]]) <{bit = 516 : i32}> : (f128) -> i1
310 ! CHECK: %[[V_17:[0-9]+]] = arith.andi %[[V_16]], %[[V_15]] : i1
311 ! CHECK: %[[V_18:[0-9]+]] = arith.ori %[[V_7]], %[[V_17]] : i1
312 ! CHECK: %[[V_19:[0-9]+]] = fir.if %[[V_18]] -> (f128) {
313 ! CHECK: fir.result %[[V_5]] : f128
315 ! CHECK: %[[V_20:[0-9]+]] = arith.cmpf oeq, %[[V_5]], %cst{{[_0-9]*}} fastmath<contract> : f128
316 ! CHECK: %[[V_21:[0-9]+]] = fir.if %[[V_20]] -> (f128) {
317 ! CHECK: %[[V_22:[0-9]+]] = arith.select %[[V_11]], %cst{{[_0-9]*}}, %cst{{[_0-9]*}} : f128
318 ! CHECK: %[[V_23:[0-9]+]] = fir.call @_FortranAMapException(%c48{{.*}}) fastmath<contract> : (i32) -> i32
319 ! CHECK: fir.call @feraiseexcept(%[[V_23]]) fastmath<contract> : (i32) -> i32
320 ! CHECK: fir.result %[[V_22]] : f128
322 ! CHECK-DAG: %[[V_22:[0-9]+]] = arith.subi %[[V_12]], %c1{{.*}} : i128
323 ! CHECK-DAG: %[[V_23:[0-9]+]] = arith.addi %[[V_12]], %c1{{.*}} : i128
324 ! CHECK: %[[V_24:[0-9]+]] = arith.select %[[V_15]], %[[V_23]], %[[V_22]] : i128
325 ! CHECK: %[[V_25:[0-9]+]] = arith.bitcast %[[V_24]] : i128 to f128
326 ! CHECK: %[[V_26:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_25]]) <{bit = 516 : i32}> : (f128) -> i1
327 ! CHECK: fir.if %[[V_26]] {
328 ! CHECK: %[[V_28:[0-9]+]] = fir.call @_FortranAMapException(%c40{{.*}}) fastmath<contract> : (i32) -> i32
329 ! CHECK: fir.call @feraiseexcept(%[[V_28]]) fastmath<contract> : (i32) -> i32
331 ! CHECK: %[[V_27:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_25]]) <{bit = 144 : i32}> : (f128) -> i1
332 ! CHECK: fir.if %[[V_27]] {
333 ! CHECK: %[[V_28:[0-9]+]] = fir.call @_FortranAMapException(%c48{{.*}}) fastmath<contract> : (i32) -> i32
334 ! CHECK: fir.call @feraiseexcept(%[[V_28]]) fastmath<contract> : (i32) -> i32
336 ! CHECK: fir.result %[[V_25]] : f128
338 ! CHECK: fir.result %[[V_21]] : f128
340 ! CHECK: fir.store %[[V_19]] to %[[V_2]] : !fir.ref<f128>
343 subroutine nearest_test6(x
, s
)
344 real(kind
=16) :: x
, s
, res
348 ! CHECK-LABEL: c.func @_QPnearest_test7
349 ! CHECK: %[[V_0:[0-9]+]] = fir.dummy_scope : !fir.dscope
350 ! CHECK: %[[V_1:[0-9]+]] = fir.alloca f128 {bindc_name = "res", uniq_name = "_QFnearest_test7Eres"}
351 ! CHECK: %[[V_2:[0-9]+]] = fir.declare %[[V_1]] {uniq_name = "_QFnearest_test7Eres"} : (!fir.ref<f128>) -> !fir.ref<f128>
352 ! CHECK: %[[V_3:[0-9]+]] = fir.declare %arg1 dummy_scope %[[V_0]] {uniq_name = "_QFnearest_test7Es"} : (!fir.ref<f32>, !fir.dscope) -> !fir.ref<f32>
353 ! CHECK: %[[V_4:[0-9]+]] = fir.declare %arg0 dummy_scope %[[V_0]] {uniq_name = "_QFnearest_test7Ex"} : (!fir.ref<f128>, !fir.dscope) -> !fir.ref<f128>
354 ! CHECK: %[[V_5:[0-9]+]] = fir.load %[[V_4]] : !fir.ref<f128>
355 ! CHECK: %[[V_6:[0-9]+]] = fir.load %[[V_3]] : !fir.ref<f32>
356 ! CHECK: %[[V_7:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_5]]) <{bit = 3 : i32}> : (f128) -> i1
357 ! CHECK: %[[V_8:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_6]]) <{bit = 96 : i32}> : (f32) -> i1
358 ! CHECK: fir.if %[[V_8]] {
359 ! CHECK: fir.call @_FortranAReportFatalUserError
361 ! CHECK: %[[V_9:[0-9]+]] = arith.bitcast %[[V_6]] : f32 to i32
362 ! CHECK: %[[V_10:[0-9]+]] = arith.shrui %[[V_9]], %c31{{.*}} : i32
363 ! CHECK: %[[V_11:[0-9]+]] = fir.convert %[[V_10]] : (i32) -> i128
364 ! CHECK: %[[V_12:[0-9]+]] = arith.cmpi ne, %[[V_11]], %c1{{.*}} : i128
365 ! CHECK: %[[V_13:[0-9]+]] = arith.bitcast %[[V_5]] : f128 to i128
366 ! CHECK: %[[V_14:[0-9]+]] = arith.shrui %[[V_13]], %c127{{.*}} : i128
367 ! CHECK: %[[V_15:[0-9]+]] = fir.convert %[[V_14]] : (i128) -> i1
368 ! CHECK: %[[V_16:[0-9]+]] = arith.cmpi ne, %[[V_12]], %[[V_15]] : i1
369 ! CHECK: %[[V_17:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_5]]) <{bit = 516 : i32}> : (f128) -> i1
370 ! CHECK: %[[V_18:[0-9]+]] = arith.andi %[[V_17]], %[[V_16]] : i1
371 ! CHECK: %[[V_19:[0-9]+]] = arith.ori %[[V_7]], %[[V_18]] : i1
372 ! CHECK: %[[V_20:[0-9]+]] = fir.if %[[V_19]] -> (f128) {
373 ! CHECK: fir.result %[[V_5]] : f128
375 ! CHECK: %[[V_21:[0-9]+]] = arith.cmpf oeq, %[[V_5]], %cst{{[_0-9]*}} fastmath<contract> : f128
376 ! CHECK: %[[V_22:[0-9]+]] = fir.if %[[V_21]] -> (f128) {
377 ! CHECK: %[[V_23:[0-9]+]] = arith.select %[[V_12]], %cst{{[_0-9]*}}, %cst{{[_0-9]*}} : f128
378 ! CHECK: %[[V_24:[0-9]+]] = fir.call @_FortranAMapException(%c48{{.*}}) fastmath<contract> : (i32) -> i32
379 ! CHECK: fir.call @feraiseexcept(%[[V_24]]) fastmath<contract> : (i32) -> i32
380 ! CHECK: fir.result %[[V_23]] : f128
382 ! CHECK-DAG: %[[V_23:[0-9]+]] = arith.subi %[[V_13]], %c1{{.*}} : i128
383 ! CHECK-DAG: %[[V_24:[0-9]+]] = arith.addi %[[V_13]], %c1{{.*}} : i128
384 ! CHECK: %[[V_25:[0-9]+]] = arith.select %[[V_16]], %[[V_24]], %[[V_23]] : i128
385 ! CHECK: %[[V_26:[0-9]+]] = arith.bitcast %[[V_25]] : i128 to f128
386 ! CHECK: %[[V_27:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_26]]) <{bit = 516 : i32}> : (f128) -> i1
387 ! CHECK: fir.if %[[V_27]] {
388 ! CHECK: %[[V_29:[0-9]+]] = fir.call @_FortranAMapException(%c40{{.*}}) fastmath<contract> : (i32) -> i32
389 ! CHECK: fir.call @feraiseexcept(%[[V_29]]) fastmath<contract> : (i32) -> i32
391 ! CHECK: %[[V_28:[0-9]+]] = "llvm.intr.is.fpclass"(%[[V_26]]) <{bit = 144 : i32}> : (f128) -> i1
392 ! CHECK: fir.if %[[V_28]] {
393 ! CHECK: %[[V_29:[0-9]+]] = fir.call @_FortranAMapException(%c48{{.*}}) fastmath<contract> : (i32) -> i32
394 ! CHECK: fir.call @feraiseexcept(%[[V_29]]) fastmath<contract> : (i32) -> i32
396 ! CHECK: fir.result %[[V_26]] : f128
398 ! CHECK: fir.result %[[V_22]] : f128
400 ! CHECK: fir.store %[[V_20]] to %[[V_2]] : !fir.ref<f128>
403 subroutine nearest_test7(x
, s
)
404 real(kind
=16) :: x
, res