@@ -202,25 +202,15 @@ func.func @roundf_func(%a: f32) -> f32 {
202
202
203
203
// CHECK-LABEL: func @powf_func
204
204
// CHECK-SAME: ([[ARG0:%.+]]: f64, [[ARG1:%.+]]: f64)
205
- func.func @powf_func (%a: f64 , %b: f64 ) ->f64 {
205
+ func.func @powf_func (%a: f64 , %b: f64 ) -> f64 {
206
206
// CHECK-DAG: [[CST0:%.+]] = arith.constant 0.000000e+00
207
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]]
208
+ // CHECK: [[LOGA:%.+]] = math.log [[ARG0]]
209
+ // CHECK: [[MULB:%.+]] = arith.mulf [[ARG1]], [[LOGA]]
210
+ // CHECK: [[EXP:%.+]] = math.exp [[MULB]]
211
+ // CHECK: [[CMPF:%.+]] = arith.cmpf oeq, [[ARG1]], [[CST0]]
212
+ // CHECK: [[SEL:%.+]] = arith.select [[CMPF]], [[CST1]], [[EXP]]
213
+ // CHECK: return [[SEL]]
224
214
%ret = math.powf %a , %b : f64
225
215
return %ret : f64
226
216
}
@@ -602,26 +592,15 @@ func.func @math_fpowi_to_powf_tensor(%0 : tensor<8xf32>, %1: tensor<8xi32>) -> t
602
592
return %2 : tensor <8 xf32 >
603
593
}
604
594
// 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
595
// 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
-
596
+ // CHECK-DAG: %[[CST0:.*]] = arith.constant dense<0.000000e+00> : tensor<8xf32>
597
+ // CHECK: %[[TOFP:.*]] = arith.sitofp %[[ARG1]] : tensor<8xi32> to tensor<8xf32>
598
+ // CHECK: %[[LOGA:.*]] = math.log %[[ARG0]] : tensor<8xf32>
599
+ // CHECK: %[[MUL:.*]] = arith.mulf %[[TOFP]], %[[LOGA]] : tensor<8xf32>
600
+ // CHECK: %[[EXP:.*]] = math.exp %[[MUL]] : tensor<8xf32>
601
+ // CHECK: %[[CMP:.*]] = arith.cmpf oeq, %[[TOFP]], %[[CST0]] : tensor<8xf32>
602
+ // CHECK: %[[SEL:.*]] = arith.select %[[CMP]], %[[CST1]], %[[EXP]] : tensor<8xi1>, tensor<8xf32>
603
+ // CHECK: return %[[SEL]]
625
604
// -----
626
605
627
606
// CHECK-LABEL: func.func @math_fpowi_to_powf_scalar
@@ -630,25 +609,15 @@ func.func @math_fpowi_to_powf_scalar(%0 : f32, %1: i64) -> f32 {
630
609
return %2 : f32
631
610
}
632
611
// 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
612
// CHECK-DAG: %[[CST0:.*]] = arith.constant 0.000000e+00 : f32
636
613
// CHECK-DAG: %[[CST1:.+]] = arith.constant 1.000000e+00 : f32
637
614
// 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
615
+ // CHECK: %[[LOGA:.*]] = math.log %[[ARG0]] : f32
616
+ // CHECK: %[[MUL:.*]] = arith.mulf %[[TOFP]], %[[LOGA]] : f32
642
617
// 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
618
+ // CHECK: %[[CMP:.*]] = arith.cmpf oeq, %[[TOFP]], %[[CST0]] : f32
619
+ // CHECK: %[[SEL:.*]] = arith.select %[[CMP]], %[[CST1]], %[[EXP]] : f32
620
+ // CHECK: return %[[SEL]] : f32
652
621
653
622
// -----
654
623
0 commit comments