[Mlir-commits] [mlir] [mlir][complex] Require fastmath for the add/sub and exp/log folds (PR #221384)

Hung-Kuan Tseng llvmlistbot at llvm.org
Fri Sep 11 07:36:16 PDT 2026


================
@@ -81,7 +93,19 @@ func.func @complex_add_sub_rhs() -> complex<f32> {
   // CHECK: %[[CPLX:.*]] = complex.constant [1.000000e+00 : f32, 0.000000e+00 : f32] : complex<f32>
   // CHECK-NEXT: return %[[CPLX]] : complex<f32>
   %sub = complex.sub %complex1, %complex2 : complex<f32>
-  %add = complex.add %complex2, %sub : complex<f32>
+  %add = complex.add %complex2, %sub fastmath<reassoc,nsz> : complex<f32>
+  return %add : complex<f32>
+}
+
+// CHECK-LABEL: func @complex_add_sub_rhs_without_fast_math
+func.func @complex_add_sub_rhs_without_fast_math() -> complex<f32> {
+  %complex1 = complex.constant [1.0 : f32, 0.0 : f32] : complex<f32>
+  %complex2 = complex.constant [0.0 : f32, 2.0 : f32] : complex<f32>
+  // CHECK: %[[SUB:.*]] = complex.sub
+  // CHECK: %[[ADD:.*]] = complex.add %[[SUB]], %{{.*}} fastmath<nsz> : complex<f32>
+  // CHECK-NEXT: return %[[ADD]] : complex<f32>
+  %sub = complex.sub %complex1, %complex2 : complex<f32>
+  %add = complex.add %complex2, %sub fastmath<nsz> : complex<f32>
----------------
Tim096 wrote:

Done, the add/sub and exp/log tests now take their operands as arguments.

https://github.com/llvm/llvm-project/pull/221384


More information about the Mlir-commits mailing list