[Mlir-commits] [mlir] [mlir][math] Expand powfI operation for constant power operand. (PR #87081)

Prashant Kumar llvmlistbot at llvm.org
Fri Mar 29 09:31:33 PDT 2024


================
@@ -202,6 +202,48 @@ static LogicalResult convertCeilOp(math::CeilOp op, PatternRewriter &rewriter) {
   rewriter.replaceOp(op, ret);
   return success();
 }
+
+// Convert `math.fpowi` to a series of `arith.mulf` operations.
+// If the power is negative, we divide one by the result.
+static LogicalResult convertFPowIOp(math::FPowIOp op,
+                                    PatternRewriter &rewriter) {
+  ImplicitLocOpBuilder b(op->getLoc(), rewriter);
+  Value operandA = op.getOperand(0);
+  Value operandB = op.getOperand(1);
+  Type opType = operandA.getType();
+  auto conOp =
+      mlir::dyn_cast<mlir::arith::ConstantOp>(operandB.getDefiningOp());
----------------
pashu123 wrote:

Done. Thanks.

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


More information about the Mlir-commits mailing list