Skip to content

Commit 180455a

Browse files
committed
[MLIR][LLVM] Expose powi intrinsic to MLIR
Expose the powi intrinsic to the LLVM dialect within MLIR Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D116364
1 parent ba9016a commit 180455a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,12 @@ class LLVM_BinarySameArgsIntrinsicOp<string func, list<OpTrait> traits = []> :
13951395
let arguments = (ins LLVM_Type:$a, LLVM_Type:$b);
13961396
}
13971397

1398+
class LLVM_BinaryIntrinsicOp<string func, list<OpTrait> traits = []> :
1399+
LLVM_OneResultIntrOp<func, [], [0,1],
1400+
!listconcat([NoSideEffect], traits)> {
1401+
let arguments = (ins LLVM_Type:$a, LLVM_Type:$b);
1402+
}
1403+
13981404
class LLVM_TernarySameArgsIntrinsicOp<string func, list<OpTrait> traits = []> :
13991405
LLVM_OneResultIntrOp<func, [], [0],
14001406
!listconcat([NoSideEffect, SameOperandsAndResultType], traits)> {
@@ -1426,6 +1432,7 @@ def LLVM_Prefetch : LLVM_ZeroResultIntrOp<"prefetch", [0]> {
14261432
def LLVM_SinOp : LLVM_UnaryIntrinsicOp<"sin">;
14271433
def LLVM_SqrtOp : LLVM_UnaryIntrinsicOp<"sqrt">;
14281434
def LLVM_PowOp : LLVM_BinarySameArgsIntrinsicOp<"pow">;
1435+
def LLVM_PowIOp : LLVM_BinaryIntrinsicOp<"powi">;
14291436
def LLVM_BitReverseOp : LLVM_UnaryIntrinsicOp<"bitreverse">;
14301437
def LLVM_CountLeadingZerosOp : LLVM_CountZerosIntrinsicOp<"ctlz">;
14311438
def LLVM_CountTrailingZerosOp : LLVM_CountZerosIntrinsicOp<"cttz">;

mlir/test/Dialect/LLVMIR/roundtrip.mlir

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ func @ops(%arg0: i32, %arg1: f32,
146146
// CHECK: "llvm.intr.pow"(%[[FLOAT]], %[[FLOAT]]) : (f32, f32) -> f32
147147
%31 = "llvm.intr.pow"(%arg1, %arg1) : (f32, f32) -> f32
148148

149+
// CHECK: "llvm.intr.powi"(%[[FLOAT]], %[[I32]]) : (f32, i32) -> f32
150+
%a31 = "llvm.intr.powi"(%arg1, %arg0) : (f32, i32) -> f32
151+
149152
// CHECK: "llvm.intr.bitreverse"(%{{.*}}) : (i32) -> i32
150153
%32 = "llvm.intr.bitreverse"(%arg0) : (i32) -> i32
151154

0 commit comments

Comments
 (0)