[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
================
@@ -175,12 +176,20 @@ PowIStrengthReduction<PowIOpTy, DivOpTy, MulOpTy>::matchAndRewrite(
Value one;
Type opType = getElementTypeOrSelf(op.getType());
- if constexpr (std::is_same_v<PowIOpTy, math::FPowIOp>)
+ if constexpr (std::is_same_v<PowIOpTy, math::FPowIOp>) {
one = arith::ConstantOp::create(rewriter, loc,
rewriter.getFloatAttr(opType, 1.0));
- else
+ } else if constexpr (std::is_same_v<PowIOpTy, complex::PowiOp>) {
+ auto complexTy = cast<ComplexType>(opType);
+ Type elementType = complexTy.getElementType();
+ auto realPart = rewriter.getFloatAttr(elementType, 1.0);
+ auto imagPart = rewriter.getFloatAttr(elementType, 0.0);
+ one = rewriter.create<complex::ConstantOp>(
----------------
vzakhari wrote:
I believe all the `create` methods of the rewriter will become deprecated soon, so `complex::ConstantOp::create` is a better alternative. There are other cases below.
https://github.com/llvm/llvm-project/pull/158722
More information about the llvm-branch-commits
mailing list