[flang-commits] [clang] [flang] [flang] Add -fcomplex-arithmetic= option and select complex division algorithm (PR #146641)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Thu Jul 3 02:31:00 PDT 2025
================
@@ -1066,8 +1066,16 @@ struct BinaryOp<Fortran::evaluate::Divide<
mlir::Type ty = Fortran::lower::getFIRType(
builder.getContext(), Fortran::common::TypeCategory::Complex, KIND,
/*params=*/{});
- return hlfir::EntityWithAttributes{
- fir::genDivC(builder, loc, ty, lhs, rhs)};
+
+ // TODO: Ideally, complex number division operations should always be
+ // lowered to MLIR. However, converting them to the runtime via MLIR causes
+ // ABI issues.
+ if (builder.getComplexDivisionToRuntimeFlag())
+ return hlfir::EntityWithAttributes{
+ fir::genDivC(builder, loc, ty, lhs, rhs)};
+ else
+ return hlfir::EntityWithAttributes{
+ builder.create<mlir::complex::DivOp>(loc, lhs, rhs)};
----------------
kiranchandramohan wrote:
Nit: braces
https://github.com/llvm/llvm-project/pull/146641
More information about the flang-commits
mailing list