@@ -511,3 +511,102 @@ func.func @roundeven16(%arg: f16) -> f16 {
511
511
// CHECK: %[[COPYSIGN:.*]] = math.copysign %[[RESULT]], %[[VAL_0]] : f16
512
512
513
513
// CHECK: return %[[COPYSIGN]] : f16
514
+
515
+ // -----
516
+
517
+ // CHECK-LABEL: func.func @math_fpowi_neg_odd_power
518
+ func.func @math_fpowi_neg_odd_power (%0 : tensor <8 xf32 >) -> tensor <8 xf32 > {
519
+ %1 = arith.constant dense <-3 > : tensor <8 xi64 >
520
+ %2 = math.fpowi %0 , %1 : tensor <8 xf32 >, tensor <8 xi64 >
521
+ return %2 : tensor <8 xf32 >
522
+ }
523
+ // CHECK-SAME: (%[[ARG0:.*]]: tensor<8xf32>) -> tensor<8xf32> {
524
+ // CHECK-DAG: %[[CST1:.*]] = arith.constant dense<1.000000e+00> : tensor<8xf32>
525
+ // CHECK-DAG: %[[CST0:.*]] = arith.constant dense<0.000000e+00> : tensor<8xf32>
526
+ // CHECK-DAG: %[[CSTNEG0:.*]] = arith.constant dense<-0.000000e+00> : tensor<8xf32>
527
+ // CHECK-DAG: %[[CSTINF:.*]] = arith.constant dense<0x7F800000> : tensor<8xf32>
528
+ // CHECK-DAG: %[[CSTNEGINF:.*]] = arith.constant dense<0xFF800000> : tensor<8xf32>
529
+ // CHECK: %[[SQ:.*]] = arith.mulf %[[ARG0]], %[[ARG0]] : tensor<8xf32>
530
+ // CHECK: %[[CUBE:.*]] = arith.mulf %[[SQ]], %[[ARG0]] : tensor<8xf32>
531
+ // CHECK: %[[CMP0:.*]] = arith.cmpf oeq, %[[CUBE]], %[[CST0]] : tensor<8xf32>
532
+ // CHECK: %[[CMPNEG0:.*]] = arith.cmpf oeq, %[[CUBE]], %[[CSTNEG0]] : tensor<8xf32>
533
+ // CHECK: %[[INV:.*]] = arith.divf %[[CST1]], %[[CUBE]] : tensor<8xf32>
534
+ // CHECK: %[[UB1:.*]] = arith.select %[[CMP0]], %[[CSTINF]], %[[INV]] : tensor<8xi1>, tensor<8xf32>
535
+ // CHECK: %[[UB2:.*]] = arith.select %[[CMPNEG0]], %[[CSTNEGINF]], %[[UB1]] : tensor<8xi1>, tensor<8xf32>
536
+ // CHECK: return %[[UB2]] : tensor<8xf32>
537
+
538
+ // -----
539
+
540
+ // CHECK-LABEL: func.func @math_fpowi_neg_even_power
541
+ func.func @math_fpowi_neg_even_power (%0 : tensor <8 xf32 >) -> tensor <8 xf32 > {
542
+ %1 = arith.constant dense <-4 > : tensor <8 xi64 >
543
+ %2 = math.fpowi %0 , %1 : tensor <8 xf32 >, tensor <8 xi64 >
544
+ return %2 : tensor <8 xf32 >
545
+ }
546
+ // CHECK-SAME: (%[[ARG0:.*]]: tensor<8xf32>) -> tensor<8xf32> {
547
+ // CHECK-DAG: %[[CST1:.*]] = arith.constant dense<1.000000e+00> : tensor<8xf32>
548
+ // CHECK-DAG: %[[CST0:.*]] = arith.constant dense<0.000000e+00> : tensor<8xf32>
549
+ // CHECK-DAG: %[[CSTNEG0:.*]] = arith.constant dense<-0.000000e+00> : tensor<8xf32>
550
+ // CHECK-DAG: %[[CSTINF:.*]] = arith.constant dense<0x7F800000> : tensor<8xf32>
551
+ // CHECK-DAG: %[[CSTNEGINF:.*]] = arith.constant dense<0xFF800000> : tensor<8xf32>
552
+ // CHECK: %[[SQ:.*]] = arith.mulf %[[ARG0]], %[[ARG0]] : tensor<8xf32>
553
+ // CHECK: %[[PW4:.*]] = arith.mulf %[[SQ]], %[[SQ]] : tensor<8xf32>
554
+ // CHECK: %[[CMP0:.*]] = arith.cmpf oeq, %[[PW4]], %[[CST0]] : tensor<8xf32>
555
+ // CHECK: %[[CMPNEG0:.*]] = arith.cmpf oeq, %[[PW4]], %[[CSTNEG0]] : tensor<8xf32>
556
+ // CHECK: %[[INV:.*]] = arith.divf %[[CST1]], %[[PW4]] : tensor<8xf32>
557
+ // CHECK: %[[UB1:.*]] = arith.select %[[CMP0]], %[[CSTINF]], %[[INV]] : tensor<8xi1>, tensor<8xf32>
558
+ // CHECK: %[[UB2:.*]] = arith.select %[[CMPNEG0]], %[[CSTNEGINF]], %[[UB1]] : tensor<8xi1>, tensor<8xf32>
559
+ // CHECK: return %[[UB2]] : tensor<8xf32>
560
+
561
+ // -----
562
+
563
+ // CHECK-LABEL: func.func @math_fpowi_pos_odd_power
564
+ func.func @math_fpowi_pos_odd_power (%0 : tensor <8 xf32 >) -> tensor <8 xf32 > {
565
+ %1 = arith.constant dense <5 > : tensor <8 xi64 >
566
+ %2 = math.fpowi %0 , %1 : tensor <8 xf32 >, tensor <8 xi64 >
567
+ return %2 : tensor <8 xf32 >
568
+ }
569
+ // CHECK-SAME: (%[[ARG0:.*]]: tensor<8xf32>) -> tensor<8xf32> {
570
+ // CHECK: %[[SQ:.*]] = arith.mulf %[[ARG0]], %[[ARG0]] : tensor<8xf32>
571
+ // CHECK: %[[PW4:.*]] = arith.mulf %[[SQ]], %[[SQ]] : tensor<8xf32>
572
+ // CHECK: %[[PW5:.*]] = arith.mulf %[[PW4]], %[[ARG0]] : tensor<8xf32>
573
+ // CHECK: return %[[PW5]] : tensor<8xf32>
574
+
575
+ // -----
576
+
577
+ // CHECK-LABEL: func.func @math_fpowi_pos_even_power
578
+ func.func @math_fpowi_pos_even_power (%0 : tensor <8 xf32 >) -> tensor <8 xf32 > {
579
+ %1 = arith.constant dense <4 > : tensor <8 xi64 >
580
+ %2 = math.fpowi %0 , %1 : tensor <8 xf32 >, tensor <8 xi64 >
581
+ return %2 : tensor <8 xf32 >
582
+ }
583
+ // CHECK-SAME: (%[[ARG0:.*]]: tensor<8xf32>) -> tensor<8xf32> {
584
+ // CHECK: %[[SQ:.*]] = arith.mulf %[[ARG0]], %[[ARG0]] : tensor<8xf32>
585
+ // CHECK: %[[PW4:.*]] = arith.mulf %[[SQ]], %[[SQ]] : tensor<8xf32>
586
+ // CHECK: return %[[PW4]] : tensor<8xf32>
587
+
588
+ // -----
589
+
590
+ // CHECK-LABEL: func.func @math_fpowi_even_scalar
591
+ func.func @math_fpowi_even_scalar (%0 : f32 ) -> f32 {
592
+ %pow = arith.constant 2 : i64
593
+ %2 = math.fpowi %0 , %pow : f32 , i64
594
+ return %2 : f32
595
+ }
596
+ // CHECK-SAME: (%[[ARG0:.*]]: f32) -> f32 {
597
+ // CHECK: %[[SQ:.*]] = arith.mulf %[[ARG0]], %[[ARG0]] : f32
598
+ // CHECK: return %[[SQ]] : f32
599
+
600
+ // -----
601
+
602
+ // CHECK-LABEL: func.func @math_fpowi_scalar_zero
603
+ func.func @math_fpowi_scalar_zero (%0 : f32 ) -> f32 {
604
+ %pow = arith.constant 0 : i64
605
+ %2 = math.fpowi %0 , %pow : f32 , i64
606
+ return %2 : f32
607
+ }
608
+ // CHECK-SAME: (%[[ARG0:.*]]: f32) -> f32 {
609
+ // CHECK: %[[RET:.*]] = arith.constant 1.000000e+00 : f32
610
+ // CHECK: return %[[RET]] : f32
611
+
612
+ // -----
0 commit comments