@@ -201,26 +201,86 @@ func.func @roundf_func(%a: f32) -> f32 {
201
201
// -----
202
202
203
203
// CHECK-LABEL: func @powf_func
204
- // CHECK-SAME: ([[ARG0:%.+]]: f64, [[ARG1:%.+]]: f64)
205
- func.func @powf_func (%a: f64 , %b: f64 ) ->f64 {
206
- // CHECK-DAG: [[CST0:%.+]] = arith.constant 0.000000e+00
207
- // CHECK-DAG: [[CST1:%.+]] = arith.constant 1.0
208
- // CHECK-DAG: [[TWO:%.+]] = arith.constant 2.000000e+00
209
- // CHECK-DAG: [[NEGONE:%.+]] = arith.constant -1.000000e+00
210
- // CHECK-DAG: [[SQR:%.+]] = arith.mulf [[ARG0]], [[ARG0]]
211
- // CHECK-DAG: [[HALF:%.+]] = arith.divf [[ARG1]], [[TWO]]
212
- // CHECK-DAG: [[LOG:%.+]] = math.log [[SQR]]
213
- // CHECK-DAG: [[MULT:%.+]] = arith.mulf [[HALF]], [[LOG]]
214
- // CHECK-DAG: [[EXPR:%.+]] = math.exp [[MULT]]
215
- // CHECK-DAG: [[NEGEXPR:%.+]] = arith.mulf [[EXPR]], [[NEGONE]]
216
- // CHECK-DAG: [[REMF:%.+]] = arith.remf [[ARG1]], [[TWO]]
217
- // CHECK-DAG: [[CMPNEG:%.+]] = arith.cmpf olt, [[ARG0]]
218
- // CHECK-DAG: [[CMPZERO:%.+]] = arith.cmpf one, [[REMF]]
219
- // CHECK-DAG: [[AND:%.+]] = arith.andi [[CMPZERO]], [[CMPNEG]]
220
- // CHECK-DAG: [[CMPZERO:%.+]] = arith.cmpf oeq, [[ARG1]], [[CST0]]
221
- // CHECK-DAG: [[SEL:%.+]] = arith.select [[AND]], [[NEGEXPR]], [[EXPR]]
222
- // CHECK-DAG: [[SEL1:%.+]] = arith.select [[CMPZERO]], [[CST1]], [[SEL]]
223
- // CHECK: return [[SEL1]]
204
+ // CHECK-SAME: (%[[ARG0:.+]]: f64, %[[ARG1:.+]]: f64) -> f64
205
+ func.func @powf_func (%a: f64 , %b: f64 ) -> f64 {
206
+ // CHECK: %[[LOGA:.+]] = math.log %[[ARG0]] : f64
207
+ // CHECK: %[[MUL:.+]] = arith.mulf %[[ARG1]], %[[LOGA]] : f64
208
+ // CHECK: %[[EXP:.+]] = math.exp %[[MUL]] : f64
209
+ // CHECK: return %[[EXP]] : f64
210
+ %ret = math.powf %a , %b : f64
211
+ return %ret : f64
212
+ }
213
+
214
+ // CHECK-LABEL: func @powf_func_zero
215
+ // CHECK-SAME: (%[[ARG0:.+]]: f64) -> f64
216
+ func.func @powf_func_zero (%a: f64 ) -> f64 {
217
+ // CHECK: %[[ONE:.+]] = arith.constant 1.000000e+00 : f64
218
+ // CHECK: return %[[ONE]] : f64
219
+ %b = arith.constant 0.0 : f64
220
+ %ret = math.powf %a , %b : f64
221
+ return %ret : f64
222
+ }
223
+
224
+ // CHECK-LABEL: func @powf_func_one
225
+ // CHECK-SAME: (%[[ARG0:.+]]: f64) -> f64
226
+ func.func @powf_func_one (%a: f64 ) -> f64 {
227
+ // CHECK: return %[[ARG0]] : f64
228
+ %b = arith.constant 1.0 : f64
229
+ %ret = math.powf %a , %b : f64
230
+ return %ret : f64
231
+ }
232
+
233
+ // CHECK-LABEL: func @powf_func_negone
234
+ // CHECK-SAME: (%[[ARG0:.+]]: f64) -> f64
235
+ func.func @powf_func_negone (%a: f64 ) -> f64 {
236
+ // CHECK: %[[CSTONE:.+]] = arith.constant 1.000000e+00 : f64
237
+ // CHECK: %[[DIV:.+]] = arith.divf %[[CSTONE]], %[[ARG0]] : f64
238
+ // CHECK: return %[[DIV]] : f64
239
+ %b = arith.constant -1.0 : f64
240
+ %ret = math.powf %a , %b : f64
241
+ return %ret : f64
242
+ }
243
+
244
+ // CHECK-LABEL: func @powf_func_half
245
+ // CHECK-SAME: (%[[ARG0:.+]]: f64) -> f64
246
+ func.func @powf_func_half (%a: f64 ) -> f64 {
247
+ // CHECK: %[[SQRT:.+]] = math.sqrt %[[ARG0]] : f64
248
+ // CHECK: return %[[SQRT]] : f64
249
+ %b = arith.constant 0.5 : f64
250
+ %ret = math.powf %a , %b : f64
251
+ return %ret : f64
252
+ }
253
+
254
+ // CHECK-LABEL: func @powf_func_neghalf
255
+ // CHECK-SAME: (%[[ARG0:.+]]: f64) -> f64
256
+ func.func @powf_func_neghalf (%a: f64 ) -> f64 {
257
+ // CHECK: %[[CSTONE:.+]] = arith.constant 1.000000e+00 : f64
258
+ // CHECK: %[[SQRT:.+]] = math.sqrt %[[ARG0]] : f64
259
+ // CHECK: %[[DIV:.+]] = arith.divf %[[CSTONE]], %[[SQRT]] : f64
260
+ // CHECK: return %[[DIV]] : f64
261
+ %b = arith.constant -0.5 : f64
262
+ %ret = math.powf %a , %b : f64
263
+ return %ret : f64
264
+ }
265
+
266
+ // CHECK-LABEL: func @powf_func_two
267
+ // CHECK-SAME: (%[[ARG0:.+]]: f64) -> f64
268
+ func.func @powf_func_two (%a: f64 ) -> f64 {
269
+ // CHECK: %[[MUL:.+]] = arith.mulf %[[ARG0]], %[[ARG0]] : f64
270
+ // CHECK: return %[[MUL]] : f64
271
+ %b = arith.constant 2.0 : f64
272
+ %ret = math.powf %a , %b : f64
273
+ return %ret : f64
274
+ }
275
+
276
+ // CHECK-LABEL: func @powf_func_negtwo
277
+ // CHECK-SAME: (%[[ARG0:.+]]: f64) -> f64
278
+ func.func @powf_func_negtwo (%a: f64 ) -> f64 {
279
+ // CHECK-DAG: %[[MUL:.+]] = arith.mulf %[[ARG0]], %[[ARG0]] : f64
280
+ // CHECK-DAG: %[[CSTONE:.+]] = arith.constant 1.000000e+00 : f64
281
+ // CHECK: %[[DIV:.+]] = arith.divf %[[CSTONE]], %[[MUL]] : f64
282
+ // CHECK: return %[[DIV]] : f64
283
+ %b = arith.constant -2.0 : f64
224
284
%ret = math.powf %a , %b : f64
225
285
return %ret : f64
226
286
}
@@ -602,26 +662,11 @@ func.func @math_fpowi_to_powf_tensor(%0 : tensor<8xf32>, %1: tensor<8xi32>) -> t
602
662
return %2 : tensor <8 xf32 >
603
663
}
604
664
// CHECK-SAME: (%[[ARG0:.*]]: tensor<8xf32>, %[[ARG1:.*]]: tensor<8xi32>) -> tensor<8xf32> {
605
- // CHECK-DAG: %[[CSTNEG1:.*]] = arith.constant dense<-1.000000e+00> : tensor<8xf32>
606
- // CHECK-DAG: %[[CST2:.*]] = arith.constant dense<2.000000e+00> : tensor<8xf32>
607
- // CHECK-DAG: %[[CST0:.*]] = arith.constant dense<0.000000e+00> : tensor<8xf32>
608
- // CHECK-DAG: %[[CST1:.+]] = arith.constant dense<1.000000e+00> : tensor<8xf32>
609
- // CHECK: %[[TOFP:.*]] = arith.sitofp %[[ARG1]] : tensor<8xi32> to tensor<8xf32>
610
- // CHECK: %[[SQ:.*]] = arith.mulf %[[ARG0]], %[[ARG0]] : tensor<8xf32>
611
- // CHECK: %[[DIV:.*]] = arith.divf %[[TOFP]], %[[CST2]] : tensor<8xf32>
612
- // CHECK: %[[LG:.*]] = math.log %[[SQ]] : tensor<8xf32>
613
- // CHECK: %[[MUL:.*]] = arith.mulf %[[DIV]], %[[LG]] : tensor<8xf32>
614
- // CHECK: %[[EXP:.*]] = math.exp %[[MUL]] : tensor<8xf32>
615
- // CHECK: %[[MUL1:.*]] = arith.mulf %[[EXP]], %[[CSTNEG1]] : tensor<8xf32>
616
- // CHECK: %[[REM:.*]] = arith.remf %[[TOFP]], %[[CST2]] : tensor<8xf32>
617
- // CHECK: %[[CMPF:.*]] = arith.cmpf olt, %[[ARG0]], %[[CST0]] : tensor<8xf32>
618
- // CHECK: %[[CMPF1:.*]] = arith.cmpf one, %[[REM]], %[[CST0]] : tensor<8xf32>
619
- // CHECK: %[[AND:.*]] = arith.andi %[[CMPF1]], %[[CMPF]] : tensor<8xi1>
620
- // CHECK: %[[CMPZERO:.*]] = arith.cmpf oeq, %[[TOFP]], %[[CST0]]
621
- // CHECK: %[[SEL:.*]] = arith.select %[[AND]], %[[MUL1]], %[[EXP]] : tensor<8xi1>, tensor<8xf32>
622
- // CHECK: %[[SEL1:.+]] = arith.select %[[CMPZERO]], %[[CST1]], %[[SEL]]
623
- // CHECK: return %[[SEL1]] : tensor<8xf32>
624
-
665
+ // CHECK: %[[TOFP:.*]] = arith.sitofp %[[ARG1]] : tensor<8xi32> to tensor<8xf32>
666
+ // CHECK: %[[LOGA:.*]] = math.log %[[ARG0]] : tensor<8xf32>
667
+ // CHECK: %[[MUL:.*]] = arith.mulf %[[TOFP]], %[[LOGA]] : tensor<8xf32>
668
+ // CHECK: %[[EXP:.*]] = math.exp %[[MUL]] : tensor<8xf32>
669
+ // CHECK: return %[[EXP]]
625
670
// -----
626
671
627
672
// CHECK-LABEL: func.func @math_fpowi_to_powf_scalar
@@ -630,25 +675,11 @@ func.func @math_fpowi_to_powf_scalar(%0 : f32, %1: i64) -> f32 {
630
675
return %2 : f32
631
676
}
632
677
// CHECK-SAME: (%[[ARG0:.*]]: f32, %[[ARG1:.*]]: i64) -> f32 {
633
- // CHECK-DAG: %[[CSTNEG1:.*]] = arith.constant -1.000000e+00 : f32
634
- // CHECK-DAG: %[[CST2:.*]] = arith.constant 2.000000e+00 : f32
635
- // CHECK-DAG: %[[CST0:.*]] = arith.constant 0.000000e+00 : f32
636
- // CHECK-DAG: %[[CST1:.+]] = arith.constant 1.000000e+00 : f32
637
678
// CHECK: %[[TOFP:.*]] = arith.sitofp %[[ARG1]] : i64 to f32
638
- // CHECK: %[[SQ:.*]] = arith.mulf %[[ARG0]], %[[ARG0]] : f32
639
- // CHECK: %[[DIV:.*]] = arith.divf %[[TOFP]], %[[CST2]] : f32
640
- // CHECK: %[[LG:.*]] = math.log %[[SQ]] : f32
641
- // CHECK: %[[MUL:.*]] = arith.mulf %[[DIV]], %[[LG]] : f32
679
+ // CHECK: %[[LOGA:.*]] = math.log %[[ARG0]] : f32
680
+ // CHECK: %[[MUL:.*]] = arith.mulf %[[TOFP]], %[[LOGA]] : f32
642
681
// CHECK: %[[EXP:.*]] = math.exp %[[MUL]] : f32
643
- // CHECK: %[[MUL1:.*]] = arith.mulf %[[EXP]], %[[CSTNEG1]] : f32
644
- // CHECK: %[[REM:.*]] = arith.remf %[[TOFP]], %[[CST2]] : f32
645
- // CHECK: %[[CMPF:.*]] = arith.cmpf olt, %[[ARG0]], %[[CST0]] : f32
646
- // CHECK: %[[CMPF1:.*]] = arith.cmpf one, %[[REM]], %[[CST0]] : f32
647
- // CHECK: %[[AND:.*]] = arith.andi %[[CMPF1]], %[[CMPF]] : i1
648
- // CHECK: %[[CMPZERO:.*]] = arith.cmpf oeq, %[[TOFP]], %[[CST0]]
649
- // CHECK: %[[SEL:.*]] = arith.select %[[AND]], %[[MUL1]], %[[EXP]] : f32
650
- // CHECK: %[[SEL1:.+]] = arith.select %[[CMPZERO]], %[[CST1]], %[[SEL]]
651
- // CHECK: return %[[SEL1]] : f32
682
+ // CHECK: return %[[EXP]] : f32
652
683
653
684
// -----
654
685
0 commit comments