[clang] [CIR] Support strict floating-point in Complex Add & Sub (PR #224851)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 21 07:15:55 PDT 2026


================
@@ -326,6 +326,24 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
     return cir::ComplexImagOp::create(*this, loc, resultType, operand);
   }
 
+  mlir::Value createComplexAdd(mlir::Location loc, mlir::Value lhs,
+                               mlir::Value rhs) {
+    cir::FenvAttr fenv;
+    if (isAnyFloatingPointType(
+            mlir::cast<cir::ComplexType>(lhs.getType()).getElementType()))
+      fenv = getConstrainedFPAttr();
+    return cir::ComplexAddOp::create(*this, loc, lhs, rhs, fenv);
----------------
erichkeane wrote:

I find myself wondering if we should just tolerate fenv on ALL operations, even if it isn't floating point.  Perhaps the answer is 'no', but 'accept and ignore' here is perhaps not an awful behavior?

Do we verify that you don't have a complex-int if you have an fenv? 

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


More information about the cfe-commits mailing list