-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[mlir][LLVMIR] Add support for tan intrinsic op #125748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-mlir-llvm @llvm/pr-subscribers-mlir Author: Paul Carabas (PaulCarabas) ChangesThis patch adds support for Tan trig. function intrinsic in LLVM dialect & adds missing import/export tests for Sin Full diff: https://github.com/llvm/llvm-project/pull/125748.diff 3 Files Affected:
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
index a7d683438ee8ab0..72fae1bdbf461df 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -107,7 +107,6 @@ def LLVM_IsFPClass : LLVM_OneResultIntrOp<"is.fpclass", [], [0], [Pure],
}
def LLVM_CopySignOp : LLVM_BinarySameArgsIntrOpF<"copysign">;
-def LLVM_CosOp : LLVM_UnaryIntrOpF<"cos">;
def LLVM_ExpOp : LLVM_UnaryIntrOpF<"exp">;
def LLVM_Exp2Op : LLVM_UnaryIntrOpF<"exp2">;
def LLVM_FAbsOp : LLVM_UnaryIntrOpF<"fabs">;
@@ -125,7 +124,6 @@ def LLVM_Prefetch : LLVM_ZeroResultIntrOp<"prefetch", [0],
> {
let arguments = (ins LLVM_AnyPointer:$addr, I32Attr:$rw, I32Attr:$hint, I32Attr:$cache);
}
-def LLVM_SinOp : LLVM_UnaryIntrOpF<"sin">;
def LLVM_RoundEvenOp : LLVM_UnaryIntrOpF<"roundeven">;
def LLVM_RoundOp : LLVM_UnaryIntrOpF<"round">;
def LLVM_FTruncOp : LLVM_UnaryIntrOpF<"trunc">;
@@ -167,6 +165,11 @@ def LLVM_SMaxOp : LLVM_BinarySameArgsIntrOpI<"smax">;
def LLVM_SMinOp : LLVM_BinarySameArgsIntrOpI<"smin">;
def LLVM_UMaxOp : LLVM_BinarySameArgsIntrOpI<"umax">;
def LLVM_UMinOp : LLVM_BinarySameArgsIntrOpI<"umin">;
+
+def LLVM_SinOp : LLVM_UnaryIntrOpF<"sin">;
+def LLVM_CosOp : LLVM_UnaryIntrOpF<"cos">;
+def LLVM_TanOp : LLVM_UnaryIntrOpF<"tan">;
+
def LLVM_SinhOp : LLVM_UnaryIntrOpF<"sinh">;
def LLVM_CoshOp : LLVM_UnaryIntrOpF<"cosh">;
def LLVM_TanhOp : LLVM_UnaryIntrOpF<"tanh">;
diff --git a/mlir/test/Target/LLVMIR/Import/intrinsic.ll b/mlir/test/Target/LLVMIR/Import/intrinsic.ll
index bd335323a2e1c93..249a0552c87f380 100644
--- a/mlir/test/Target/LLVMIR/Import/intrinsic.ll
+++ b/mlir/test/Target/LLVMIR/Import/intrinsic.ll
@@ -101,12 +101,23 @@ define void @floor_test(float %0, <8 x float> %1) {
%4 = call <8 x float> @llvm.floor.v8f32(<8 x float> %1)
ret void
}
-; CHECK-LABEL: llvm.func @cos_test
-define void @cos_test(float %0, <8 x float> %1) {
+; CHECK-LABEL: llvm.func @trig_test
+define void @trig_test(float %0, <8 x float> %1) {
+ ; CHECK: llvm.intr.sin(%{{.*}}) : (f32) -> f32
+ %3 = call float @llvm.sin.f32(float %0)
+ ; CHECK: llvm.intr.sin(%{{.*}}) : (vector<8xf32>) -> vector<8xf32>
+ %4 = call <8 x float> @llvm.sin.v8f32(<8 x float> %1)
+
; CHECK: llvm.intr.cos(%{{.*}}) : (f32) -> f32
- %3 = call float @llvm.cos.f32(float %0)
+ %5 = call float @llvm.cos.f32(float %0)
; CHECK: llvm.intr.cos(%{{.*}}) : (vector<8xf32>) -> vector<8xf32>
- %4 = call <8 x float> @llvm.cos.v8f32(<8 x float> %1)
+ %6 = call <8 x float> @llvm.cos.v8f32(<8 x float> %1)
+
+ ; CHECK: llvm.intr.tan(%{{.*}}) : (f32) -> f32
+ %7 = call float @llvm.tan.f32(float %0)
+ ; CHECK: llvm.intr.tan(%{{.*}}) : (vector<8xf32>) -> vector<8xf32>
+ %8 = call <8 x float> @llvm.tan.v8f32(<8 x float> %1)
+
ret void
}
; CHECK-LABEL: llvm.func @hyperbolic_trig_test
diff --git a/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir b/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
index 382b2b9f3cd732e..2c208789e36ddbe 100644
--- a/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
@@ -103,12 +103,22 @@ llvm.func @floor_test(%arg0: f32, %arg1: vector<8xf32>) {
llvm.return
}
-// CHECK-LABEL: @cos_test
-llvm.func @cos_test(%arg0: f32, %arg1: vector<8xf32>) {
+// CHECK-LABEL: @trig_test
+llvm.func @trig_test(%arg0: f32, %arg1: vector<8xf32>) {
+ // CHECK: call float @llvm.sin.f32
+ llvm.intr.sin(%arg0) : (f32) -> f32
+ // CHECK: call <8 x float> @llvm.sin.v8f32
+ llvm.intr.sin(%arg1) : (vector<8xf32>) -> vector<8xf32>
+
// CHECK: call float @llvm.cos.f32
- "llvm.intr.cos"(%arg0) : (f32) -> f32
+ llvm.intr.cos(%arg0) : (f32) -> f32
// CHECK: call <8 x float> @llvm.cos.v8f32
- "llvm.intr.cos"(%arg1) : (vector<8xf32>) -> vector<8xf32>
+ llvm.intr.cos(%arg1) : (vector<8xf32>) -> vector<8xf32>
+
+ // CHECK: call float @llvm.tan.f32
+ llvm.intr.tan(%arg0) : (f32) -> f32
+ // CHECK: call <8 x float> @llvm.tan.v8f32
+ llvm.intr.tan(%arg1) : (vector<8xf32>) -> vector<8xf32>
llvm.return
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, good cleanup, thanks!
@krzysz00 would you also be able to help with the merge, please? Thanks! |
@PaulCarabas Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
This patch adds support for Tan trig. function intrinsic in LLVM dialect & adds missing import/export tests for Sin
This is similar to #125748
…p (#127317) This is similar to llvm/llvm-project#125748
This patch adds support for Tan trig. function intrinsic in LLVM dialect & adds missing import/export tests for Sin