[Mlir-commits] [mlir] 7c3439b - [mlir][llvm] Add `llvm.intr.is.fpclass`
Jeff Niu
llvmlistbot at llvm.org
Fri Oct 14 16:23:09 PDT 2022
Author: Jeff Niu
Date: 2022-10-14T16:22:59-07:00
New Revision: 7c3439b74c2b31fccd03876a0e543d275fd37f81
URL: https://github.com/llvm/llvm-project/commit/7c3439b74c2b31fccd03876a0e543d275fd37f81
DIFF: https://github.com/llvm/llvm-project/commit/7c3439b74c2b31fccd03876a0e543d275fd37f81.diff
LOG: [mlir][llvm] Add `llvm.intr.is.fpclass`
This intrinsic allows testing for inf, nan, etc. on floating point
values.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D135969
Added:
Modified:
mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
index 75e1050b06c63..fd748f79bd335 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -44,6 +44,11 @@ def LLVM_AbsOp : LLVM_OneResultIntrOp<"abs", [], [0], [Pure]> {
let arguments = (ins LLVM_Type:$in, I1:$is_int_min_poison);
}
+def LLVM_IsFPClass : LLVM_OneResultIntrOp<"is.fpclass", [], [0],
+ [NoSideEffect]> {
+ let arguments = (ins LLVM_Type:$in, I32:$bit);
+}
+
def LLVM_CopySignOp : LLVM_BinarySameArgsIntrinsicOp<"copysign">;
def LLVM_CosOp : LLVM_UnaryIntrinsicOp<"cos">;
def LLVM_ExpOp : LLVM_UnaryIntrinsicOp<"exp">;
diff --git a/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir b/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
index a3b894dced804..78fc159d0da31 100644
--- a/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
@@ -18,6 +18,14 @@ llvm.func @intrinsics(%arg0: f32, %arg1: f32, %arg2: vector<8xf32>, %arg3: !llvm
llvm.return
}
+// CHECK-LABEL: @fpclass_test
+llvm.func @fpclass_test(%arg0: f32) -> i1 {
+ %checkNan = llvm.mlir.constant(0 : i32) : i32
+ // CHECK: call i1 @llvm.is.fpclass
+ %0 = "llvm.intr.is.fpclass"(%arg0, %checkNan) : (f32, i32) -> i1
+ llvm.return %0 : i1
+}
+
// CHECK-LABEL: @exp_test
llvm.func @exp_test(%arg0: f32, %arg1: vector<8xf32>) {
// CHECK: call float @llvm.exp.f32
More information about the Mlir-commits
mailing list