[Mlir-commits] [mlir] 70174b8 - [mlir][math] Added math::FPowI conversion to LLVM dialect.

Slava Zakharin llvmlistbot at llvm.org
Wed Dec 14 10:15:15 PST 2022


Author: Slava Zakharin
Date: 2022-12-14T10:15:05-08:00
New Revision: 70174b8035da3f28ef651ee8de96bcfa6d688ada

URL: https://github.com/llvm/llvm-project/commit/70174b8035da3f28ef651ee8de96bcfa6d688ada
DIFF: https://github.com/llvm/llvm-project/commit/70174b8035da3f28ef651ee8de96bcfa6d688ada.diff

LOG: [mlir][math] Added math::FPowI conversion to LLVM dialect.

The operations are converted into LLVM::PowIOp.

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D129812

Added: 
    

Modified: 
    mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp
    mlir/test/Conversion/MathToLLVM/math-to-llvm.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp b/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp
index b5ce019b20832..ece80921e29b1 100644
--- a/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp
+++ b/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp
@@ -50,6 +50,8 @@ using Log10OpLowering =
 using Log2OpLowering = ConvertFMFMathToLLVMPattern<math::Log2Op, LLVM::Log2Op>;
 using LogOpLowering = ConvertFMFMathToLLVMPattern<math::LogOp, LLVM::LogOp>;
 using PowFOpLowering = ConvertFMFMathToLLVMPattern<math::PowFOp, LLVM::PowOp>;
+using FPowIOpLowering =
+    ConvertFMFMathToLLVMPattern<math::FPowIOp, LLVM::PowIOp>;
 using RoundEvenOpLowering =
     ConvertFMFMathToLLVMPattern<math::RoundEvenOp, LLVM::RoundEvenOp>;
 using RoundOpLowering =
@@ -313,6 +315,7 @@ void mlir::populateMathToLLVMConversionPatterns(LLVMTypeConverter &converter,
     Exp2OpLowering,
     ExpM1OpLowering,
     ExpOpLowering,
+    FPowIOpLowering,
     FloorOpLowering,
     FmaOpLowering,
     Log10OpLowering,

diff  --git a/mlir/test/Conversion/MathToLLVM/math-to-llvm.mlir b/mlir/test/Conversion/MathToLLVM/math-to-llvm.mlir
index 8c7f031cb97d9..3b119a91b3164 100644
--- a/mlir/test/Conversion/MathToLLVM/math-to-llvm.mlir
+++ b/mlir/test/Conversion/MathToLLVM/math-to-llvm.mlir
@@ -256,6 +256,17 @@ func.func @rsqrt_multidim_vector(%arg0 : vector<4x3xf32>) {
   func.return
 }
 
+// -----
+
+// CHECK-LABEL: func @fpowi(
+// CHECK-SAME: f64
+func.func @fpowi(%arg0 : f64, %arg1 : i32) {
+  // CHECK: llvm.intr.powi(%arg0, %arg1) : (f64, i32) -> f64
+  %0 = math.fpowi %arg0, %arg1 : f64, i32
+  func.return
+}
+
+
 // -----
 
 // CHECK-LABEL: func @powf(


        


More information about the Mlir-commits mailing list