@@ -723,3 +723,37 @@ func.func @complex_abs_with_fmf(%arg: complex<f32>) -> f32 {
723
723
// CHECK: %[[SQ_NORM:.*]] = arith.addf %[[REAL_SQ]], %[[IMAG_SQ]] fastmath<nnan,contract> : f32
724
724
// CHECK: %[[NORM:.*]] = math.sqrt %[[SQ_NORM]] : f32
725
725
// CHECK: return %[[NORM]] : f32
726
+
727
+ // -----
728
+
729
+ // CHECK-LABEL: func @complex_add_with_fmf
730
+ // CHECK-SAME: (%[[LHS:.*]]: complex<f32>, %[[RHS:.*]]: complex<f32>)
731
+ func.func @complex_add_with_fmf (%lhs: complex <f32 >, %rhs: complex <f32 >) -> complex <f32 > {
732
+ %add = complex.add %lhs , %rhs fastmath <nnan ,contract > : complex <f32 >
733
+ return %add : complex <f32 >
734
+ }
735
+ // CHECK: %[[REAL_LHS:.*]] = complex.re %[[LHS]] : complex<f32>
736
+ // CHECK: %[[REAL_RHS:.*]] = complex.re %[[RHS]] : complex<f32>
737
+ // CHECK: %[[RESULT_REAL:.*]] = arith.addf %[[REAL_LHS]], %[[REAL_RHS]] fastmath<nnan,contract> : f32
738
+ // CHECK: %[[IMAG_LHS:.*]] = complex.im %[[LHS]] : complex<f32>
739
+ // CHECK: %[[IMAG_RHS:.*]] = complex.im %[[RHS]] : complex<f32>
740
+ // CHECK: %[[RESULT_IMAG:.*]] = arith.addf %[[IMAG_LHS]], %[[IMAG_RHS]] fastmath<nnan,contract> : f32
741
+ // CHECK: %[[RESULT:.*]] = complex.create %[[RESULT_REAL]], %[[RESULT_IMAG]] : complex<f32>
742
+ // CHECK: return %[[RESULT]] : complex<f32>
743
+
744
+ // -----
745
+
746
+ // CHECK-LABEL: func @complex_sub_with_fmf
747
+ // CHECK-SAME: (%[[LHS:.*]]: complex<f32>, %[[RHS:.*]]: complex<f32>)
748
+ func.func @complex_sub_with_fmf (%lhs: complex <f32 >, %rhs: complex <f32 >) -> complex <f32 > {
749
+ %sub = complex.sub %lhs , %rhs fastmath <nnan ,contract > : complex <f32 >
750
+ return %sub : complex <f32 >
751
+ }
752
+ // CHECK: %[[REAL_LHS:.*]] = complex.re %[[LHS]] : complex<f32>
753
+ // CHECK: %[[REAL_RHS:.*]] = complex.re %[[RHS]] : complex<f32>
754
+ // CHECK: %[[RESULT_REAL:.*]] = arith.subf %[[REAL_LHS]], %[[REAL_RHS]] fastmath<nnan,contract> : f32
755
+ // CHECK: %[[IMAG_LHS:.*]] = complex.im %[[LHS]] : complex<f32>
756
+ // CHECK: %[[IMAG_RHS:.*]] = complex.im %[[RHS]] : complex<f32>
757
+ // CHECK: %[[RESULT_IMAG:.*]] = arith.subf %[[IMAG_LHS]], %[[IMAG_RHS]] fastmath<nnan,contract> : f32
758
+ // CHECK: %[[RESULT:.*]] = complex.create %[[RESULT_REAL]], %[[RESULT_IMAG]] : complex<f32>
759
+ // CHECK: return %[[RESULT]] : complex<f32>
0 commit comments