Skip to content

[MLIR][LLVMIR] Add support for atan2 intrinsics op #127970

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 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ 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_ATan2Op : LLVM_BinarySameArgsIntrOpF<"atan2">;

def LLVM_SinhOp : LLVM_UnaryIntrOpF<"sinh">;
def LLVM_CoshOp : LLVM_UnaryIntrOpF<"cosh">;
Expand Down
8 changes: 8 additions & 0 deletions mlir/test/Target/LLVMIR/Import/intrinsic.ll
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ define void @inv_trig_test(float %0, <8 x float> %1) {

ret void
}
; CHECK-LABEL: llvm.func @atan2_test
define void @atan2_test(float %0, float %1, <8 x float> %2, <8 x float> %3) {
; CHECK: llvm.intr.atan2(%{{.*}}, %{{.*}}) : (f32, f32) -> f32
%5 = call float @llvm.atan2.f32(float %0, float %1)
; CHECK: llvm.intr.atan2(%{{.*}}, %{{.*}}) : (vector<8xf32>, vector<8xf32>) -> vector<8xf32>
%6 = call <8 x float> @llvm.atan2.v8f32(<8 x float> %2, <8 x float> %3)
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
Expand Down
9 changes: 9 additions & 0 deletions mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ llvm.func @inv_trig_test(%arg0: f32, %arg1: vector<8xf32>) {
llvm.return
}

// CHECK-LABEL: @atan2_test
llvm.func @atan2_test(%arg0: f32, %arg1: f32, %arg2: vector<8xf32>, %arg3: vector<8xf32>) {
// CHECK: call float @llvm.atan2.f32
"llvm.intr.atan2"(%arg0, %arg1) : (f32, f32) -> f32
// CHECK: call <8 x float> @llvm.atan2.v8f32
"llvm.intr.atan2"(%arg2, %arg3) : (vector<8xf32>, 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
Expand Down