Skip to content

[MLIR][LLVMIR] Add support for asin acos atan intrinsics op #127317

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

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

FantasqueX
Copy link
Contributor

This is similar to #125748

@llvmbot
Copy link
Member

llvmbot commented Feb 15, 2025

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-llvm

Author: FantasqueX (FantasqueX)

Changes

This is similar to #125748


Full diff: https://github.com/llvm/llvm-project/pull/127317.diff

3 Files Affected:

  • (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td (+4)
  • (modified) mlir/test/Target/LLVMIR/Import/intrinsic.ll (+19)
  • (modified) mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir (+20)
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
index 72fae1bdbf461..c270b0898f865 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -170,6 +170,10 @@ def LLVM_SinOp : LLVM_UnaryIntrOpF<"sin">;
 def LLVM_CosOp : LLVM_UnaryIntrOpF<"cos">;
 def LLVM_TanOp : LLVM_UnaryIntrOpF<"tan">;
 
+def LLVM_ASinOp : LLVM_UnaryIntrOpF<"asin">;
+def LLVM_ACosOp : LLVM_UnaryIntrOpF<"acos">;
+def LLVM_ATanOp : LLVM_UnaryIntrOpF<"atan">;
+
 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 249a0552c87f3..569b0def37856 100644
--- a/mlir/test/Target/LLVMIR/Import/intrinsic.ll
+++ b/mlir/test/Target/LLVMIR/Import/intrinsic.ll
@@ -120,6 +120,25 @@ define void @trig_test(float %0, <8 x float> %1) {
 
   ret void
 }
+; CHECK-LABEL:  llvm.func @inv_trig_test
+define void @inv_trig_test(float %0, <8 x float> %1) {
+  ; CHECK: llvm.intr.asin(%{{.*}}) : (f32) -> f32
+  %3 = call float @llvm.asin.f32(float %0)
+  ; CHECK: llvm.intr.asin(%{{.*}}) : (vector<8xf32>) -> vector<8xf32>
+  %4 = call <8 x float> @llvm.asin.v8f32(<8 x float> %1)
+
+  ; CHECK: llvm.intr.acos(%{{.*}}) : (f32) -> f32
+  %5 = call float @llvm.acos.f32(float %0)
+  ; CHECK: llvm.intr.acos(%{{.*}}) : (vector<8xf32>) -> vector<8xf32>
+  %6 = call <8 x float> @llvm.acos.v8f32(<8 x float> %1)
+
+  ; CHECK: llvm.intr.atan(%{{.*}}) : (f32) -> f32
+  %7 = call float @llvm.atan.f32(float %0)
+  ; CHECK: llvm.intr.atan(%{{.*}}) : (vector<8xf32>) -> vector<8xf32>
+  %8 = call <8 x float> @llvm.atan.v8f32(<8 x float> %1)
+
+  ret void
+}
 ; CHECK-LABEL:  llvm.func @hyperbolic_trig_test
 define void @hyperbolic_trig_test(float %0, <8 x float> %1) {
   ; CHECK: llvm.intr.sinh(%{{.*}}) : (f32) -> f32
diff --git a/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir b/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
index 2c208789e36dd..3616a2e3c7b21 100644
--- a/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
@@ -122,6 +122,26 @@ llvm.func @trig_test(%arg0: f32, %arg1: vector<8xf32>) {
   llvm.return
 }
 
+// CHECK-LABEL: @inv_trig_test
+llvm.func @inv_trig_test(%arg0: f32, %arg1: vector<8xf32>) {
+  // CHECK: call float @llvm.asin.f32
+  llvm.intr.asin(%arg0) : (f32) -> f32
+  // CHECK: call <8 x float> @llvm.asin.v8f32
+  llvm.intr.asin(%arg1) : (vector<8xf32>) -> vector<8xf32>
+
+  // CHECK: call float @llvm.acos.f32
+  llvm.intr.acos(%arg0) : (f32) -> f32
+  // CHECK: call <8 x float> @llvm.acos.v8f32
+  llvm.intr.acos(%arg1) : (vector<8xf32>) -> vector<8xf32>
+
+  // CHECK: call float @llvm.atan.f32
+  llvm.intr.atan(%arg0) : (f32) -> f32
+  // CHECK: call <8 x float> @llvm.atan.v8f32
+  llvm.intr.atan(%arg1) : (vector<8xf32>) -> vector<8xf32>
+
+  llvm.return
+}
+
 // CHECK-LABEL: @hyperbolic_trig_test
 llvm.func @hyperbolic_trig_test(%arg0: f32, %arg1: vector<8xf32>) {
   // CHECK: call float @llvm.sinh.f32

Copy link
Contributor

@Dinistro Dinistro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the extension 🙂

Copy link
Contributor

@ashermancinelli ashermancinelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bcardosolopes bcardosolopes merged commit 5caefe2 into llvm:main Feb 19, 2025
11 checks passed
bcardosolopes pushed a commit that referenced this pull request Feb 27, 2025
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Feb 27, 2025
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants