[flang-commits] [flang] [mlir] [MLIR] Add cpow support in ComplexToROCDLLibraryCalls (PR #153183)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Mon Aug 18 09:00:58 PDT 2025


================
@@ -1625,15 +1655,19 @@ static constexpr MathOperation mathOperations[] = {
      genFuncType<Ty::Real<16>, Ty::Real<16>, Ty::Integer<8>>,
      genMathOp<mlir::math::FPowIOp>},
     {"pow", RTNAME_STRING(cpowi),
-     genFuncType<Ty::Complex<4>, Ty::Complex<4>, Ty::Integer<4>>, genLibCall},
+     genFuncType<Ty::Complex<4>, Ty::Complex<4>, Ty::Integer<4>>,
+     genComplexPow},
----------------
vzakhari wrote:

I think it will be better to handle these cases same way as the other intrinsics where we can generate either a lib call or an MLIR operation, e.g.:
```
    {"pow", RTNAME_STRING(FPow4i),
     genFuncType<Ty::Real<4>, Ty::Real<4>, Ty::Integer<4>>,
     genMathOp<mlir::math::FPowIOp>},
```

Then, you may have a ROCDL specific pass that converts the complex operations into AMD GPU code, and a Flang pipeline pass that converts the complex operations into the runtime calls. You may also have a pass that does the canonicalization/folding for the constant exponent cases.

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


More information about the flang-commits mailing list