class LLVM_CountZerosIntrinsicOp<string func, list<Trait> traits = []> :
LLVM_OneResultIntrOp<func, [], [0],
!listconcat([NoSideEffect], traits)> {
- let arguments = (ins LLVM_Type:$in, I<1>:$zero_undefined);
+ let arguments = (ins LLVM_Type:$in, I1:$zero_undefined);
+}
+
+def LLVM_AbsOp : LLVM_OneResultIntrOp<"abs", [], [0], [NoSideEffect]> {
+ let arguments = (ins LLVM_Type:$in, I1:$is_int_min_poison);
}
-def LLVM_AbsOp : LLVM_UnaryIntrinsicOp<"abs">;
def LLVM_CopySignOp : LLVM_BinarySameArgsIntrinsicOp<"copysign">;
def LLVM_CosOp : LLVM_UnaryIntrinsicOp<"cos">;
def LLVM_ExpOp : LLVM_UnaryIntrinsicOp<"exp">;
namespace {
using AbsFOpLowering = VectorConvertToLLVMPattern<math::AbsFOp, LLVM::FAbsOp>;
-using AbsIOpLowering = VectorConvertToLLVMPattern<math::AbsIOp, LLVM::AbsOp>;
using CeilOpLowering = VectorConvertToLLVMPattern<math::CeilOp, LLVM::FCeilOp>;
using CopySignOpLowering =
VectorConvertToLLVMPattern<math::CopySignOp, LLVM::CopySignOp>;
using SinOpLowering = VectorConvertToLLVMPattern<math::SinOp, LLVM::SinOp>;
using SqrtOpLowering = VectorConvertToLLVMPattern<math::SqrtOp, LLVM::SqrtOp>;
-// A `CtLz/CtTz(a)` is converted into `CtLz/CtTz(a, false)`.
+// A `CtLz/CtTz/absi(a)` is converted into `CtLz/CtTz/absi(a, false)`.
template <typename MathOp, typename LLVMOp>
-struct CountOpLowering : public ConvertOpToLLVMPattern<MathOp> {
+struct IntOpWithFlagLowering : public ConvertOpToLLVMPattern<MathOp> {
using ConvertOpToLLVMPattern<MathOp>::ConvertOpToLLVMPattern;
- using Super = CountOpLowering<MathOp, LLVMOp>;
+ using Super = IntOpWithFlagLowering<MathOp, LLVMOp>;
LogicalResult
matchAndRewrite(MathOp op, typename MathOp::Adaptor adaptor,
};
using CountLeadingZerosOpLowering =
- CountOpLowering<math::CountLeadingZerosOp, LLVM::CountLeadingZerosOp>;
+ IntOpWithFlagLowering<math::CountLeadingZerosOp, LLVM::CountLeadingZerosOp>;
using CountTrailingZerosOpLowering =
- CountOpLowering<math::CountTrailingZerosOp, LLVM::CountTrailingZerosOp>;
+ IntOpWithFlagLowering<math::CountTrailingZerosOp, LLVM::CountTrailingZerosOp>;
+using AbsIOpLowering = IntOpWithFlagLowering<math::AbsIOp, LLVM::AbsOp>;
// A `expm1` is converted into `exp - 1`.
struct ExpM1OpLowering : public ConvertOpToLLVMPattern<math::ExpM1Op> {
%2 = math.sqrt %arg0 : f32
// CHECK: = "llvm.intr.sqrt"(%{{.*}}) : (f64) -> f64
%3 = math.sqrt %arg4 : f64
- // CHECK: = "llvm.intr.abs"(%{{.*}}) : (i32) -> i32
- %4 = math.absi %arg2 : i32
func.return
}
// -----
+func.func @absi(%arg0: i32) -> i32 {
+ // CHECK: %[[FALSE:.*]] = llvm.mlir.constant(false
+ // CHECK: = "llvm.intr.abs"(%{{.*}}, %[[FALSE]]) : (i32, i1) -> i32
+ %0 = math.absi %arg0 : i32
+ return %0 : i32
+}
+
+// -----
+
// CHECK-LABEL: func @log1p(
// CHECK-SAME: f32
func.func @log1p(%arg0 : f32) {