[llvm-branch-commits] [flang] [mlir] [MLIR] Add new complex.powi op (PR #158722)

Slava Zakharin via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Sep 18 09:53:07 PDT 2025


================
@@ -1272,7 +1272,18 @@ mlir::Value genMathOp(fir::FirOpBuilder &builder, mlir::Location loc,
     LLVM_DEBUG(llvm::dbgs() << "Generating '" << mathLibFuncName
                             << "' operation with type ";
                mathLibFuncType.dump(); llvm::dbgs() << "\n");
-    result = T::create(builder, loc, args);
+    if constexpr (std::is_same_v<T, mlir::complex::PowOp>) {
+      auto resultType = mathLibFuncType.getResult(0);
+      result = T::create(builder, loc, resultType, args);
+    } else if constexpr (std::is_same_v<T, mlir::complex::PowiOp>) {
+      auto resultType = mathLibFuncType.getResult(0);
+      auto fmfAttr = mlir::arith::FastMathFlagsAttr::get(
+          builder.getContext(), builder.getFastMathFlags());
+      result = builder.create<mlir::complex::PowiOp>(loc, resultType, args[0],
+                                                     args[1], fmfAttr);
+    } else {
----------------
vzakhari wrote:

Do we really need all this code?  I believe just a simple `T::create(buider, loc, args)` should work, because of the type constraints in the operations definitions.

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


More information about the llvm-branch-commits mailing list