Skip to content

Commit 88d6f18

Browse files
committed
[mlir] fixed invalid LLVM intrinsics in LLVMOPs.td and llvmir-intrinsics.mlir.
Summary: The intrinsic operation added multiple type annotations to the llvm intrinsic operations, but only one is needed. The related tests in llvmir-intrinsics.mlir checked the wrong number and are adjusted as well. Reviewers: nicolasvasilache, ftynse Reviewed By: ftynse Subscribers: merge_guards_bot, ftynse, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, arpith-jacob, mgester, lucyrfox, liufengdb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73470
1 parent 664d2f5 commit 88d6f18

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -654,30 +654,30 @@ class LLVM_UnaryIntrinsicOp<string func, list<OpTrait> traits = []> :
654654
"{$in->getType()}), {$in});"> {
655655
}
656656

657-
class LLVM_BinaryIntrinsicOp<string func, list<OpTrait> traits = []> :
657+
class LLVM_BinarySameArgsIntrinsicOp<string func, list<OpTrait> traits = []> :
658658
LLVM_OneResultOp<"intr." # func,
659659
!listconcat([NoSideEffect, SameOperandsAndResultType], traits)>,
660660
Arguments<(ins LLVM_Type:$a, LLVM_Type:$b)>,
661661
LLVM_Builder<"$res = builder.CreateCall(llvm::Intrinsic::getDeclaration("
662662
"builder.GetInsertBlock()->getModule(), llvm::Intrinsic::" # func # ","
663-
"{$a->getType(), $b->getType()}), {$a, $b});"> {
663+
"{$a->getType()}), {$a, $b});"> {
664664
}
665665

666-
class LLVM_TernaryIntrinsicOp<string func, list<OpTrait> traits = []> :
666+
class LLVM_TernarySameArgsIntrinsicOp<string func, list<OpTrait> traits = []> :
667667
LLVM_OneResultOp<"intr." # func,
668668
!listconcat([NoSideEffect, SameOperandsAndResultType], traits)>,
669669
Arguments<(ins LLVM_Type:$a, LLVM_Type:$b, LLVM_Type:$c)>,
670670
LLVM_Builder<"$res = builder.CreateCall(llvm::Intrinsic::getDeclaration("
671671
"builder.GetInsertBlock()->getModule(), llvm::Intrinsic::" # func # ","
672-
"{$a->getType(), $b->getType(), $c->getType()}), {$a, $b, $c});"> {
672+
"{$a->getType()}), {$a, $b, $c});"> {
673673
}
674674

675675
def LLVM_ExpOp : LLVM_UnaryIntrinsicOp<"exp">;
676676
def LLVM_FAbsOp : LLVM_UnaryIntrinsicOp<"fabs">;
677677
def LLVM_FCeilOp : LLVM_UnaryIntrinsicOp<"ceil">;
678678
def LLVM_CosOp : LLVM_UnaryIntrinsicOp<"cos">;
679-
def LLVM_CopySignOp : LLVM_BinaryIntrinsicOp<"copysign">;
680-
def LLVM_FMulAddOp : LLVM_TernaryIntrinsicOp<"fmuladd">;
679+
def LLVM_CopySignOp : LLVM_BinarySameArgsIntrinsicOp<"copysign">;
680+
def LLVM_FMulAddOp : LLVM_TernarySameArgsIntrinsicOp<"fmuladd">;
681681

682682
def LLVM_LogOp : LLVM_Op<"intr.log", [NoSideEffect]>,
683683
Arguments<(ins LLVM_Type:$in)>,

mlir/test/Target/llvmir-intrinsics.mlir

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ llvm.func @intrinsics(%arg0: !llvm.float, %arg1: !llvm.float, %arg2: !llvm<"<8 x
55
%c3 = llvm.mlir.constant(3 : i32) : !llvm.i32
66
%c1 = llvm.mlir.constant(1 : i32) : !llvm.i32
77
%c0 = llvm.mlir.constant(0 : i32) : !llvm.i32
8-
// CHECK: call float @llvm.fmuladd.f32.f32.f32
8+
// CHECK: call float @llvm.fmuladd.f32
99
"llvm.intr.fmuladd"(%arg0, %arg1, %arg0) : (!llvm.float, !llvm.float, !llvm.float) -> !llvm.float
10-
// CHECK: call <8 x float> @llvm.fmuladd.v8f32.v8f32.v8f32
10+
// CHECK: call <8 x float> @llvm.fmuladd.v8f32
1111
"llvm.intr.fmuladd"(%arg2, %arg2, %arg2) : (!llvm<"<8 x float>">, !llvm<"<8 x float>">, !llvm<"<8 x float>">) -> !llvm<"<8 x float>">
1212
// CHECK: call void @llvm.prefetch.p0i8(i8* %3, i32 0, i32 3, i32 1)
1313
"llvm.intr.prefetch"(%arg3, %c0, %c3, %c1) : (!llvm<"i8*">, !llvm.i32, !llvm.i32, !llvm.i32) -> ()
@@ -87,8 +87,8 @@ llvm.func @copysign_test(%arg0: !llvm.float, %arg1: !llvm.float, %arg2: !llvm<"<
8787
}
8888

8989
// Check that intrinsics are declared with appropriate types.
90-
// CHECK: declare float @llvm.fmuladd.f32.f32.f32(float, float, float)
91-
// CHECK: declare <8 x float> @llvm.fmuladd.v8f32.v8f32.v8f32(<8 x float>, <8 x float>, <8 x float>) #0
90+
// CHECK: declare float @llvm.fmuladd.f32(float, float, float)
91+
// CHECK: declare <8 x float> @llvm.fmuladd.v8f32(<8 x float>, <8 x float>, <8 x float>) #0
9292
// CHECK: declare void @llvm.prefetch.p0i8(i8* nocapture readonly, i32 immarg, i32 immarg, i32)
9393
// CHECK: declare float @llvm.exp.f32(float)
9494
// CHECK: declare <8 x float> @llvm.exp.v8f32(<8 x float>) #0
@@ -104,3 +104,4 @@ llvm.func @copysign_test(%arg0: !llvm.float, %arg1: !llvm.float, %arg2: !llvm<"<
104104
// CHECK: declare <8 x float> @llvm.ceil.v8f32(<8 x float>) #0
105105
// CHECK: declare float @llvm.cos.f32(float)
106106
// CHECK: declare <8 x float> @llvm.cos.v8f32(<8 x float>) #0
107+
// CHECK: declare float @llvm.copysign.f32(float, float)

0 commit comments

Comments
 (0)