Skip to content

Commit 403b7b6

Browse files
authored
[MLIR][LLVMIR] Add support for atan2 intrinsics op (#127970)
This is similar to #127317
1 parent d2e6662 commit 403b7b6

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def LLVM_TanOp : LLVM_UnaryIntrOpF<"tan">;
173173
def LLVM_ASinOp : LLVM_UnaryIntrOpF<"asin">;
174174
def LLVM_ACosOp : LLVM_UnaryIntrOpF<"acos">;
175175
def LLVM_ATanOp : LLVM_UnaryIntrOpF<"atan">;
176+
def LLVM_ATan2Op : LLVM_BinarySameArgsIntrOpF<"atan2">;
176177

177178
def LLVM_SinhOp : LLVM_UnaryIntrOpF<"sinh">;
178179
def LLVM_CoshOp : LLVM_UnaryIntrOpF<"cosh">;

mlir/test/Target/LLVMIR/Import/intrinsic.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ define void @inv_trig_test(float %0, <8 x float> %1) {
139139

140140
ret void
141141
}
142+
; CHECK-LABEL: llvm.func @atan2_test
143+
define void @atan2_test(float %0, float %1, <8 x float> %2, <8 x float> %3) {
144+
; CHECK: llvm.intr.atan2(%{{.*}}, %{{.*}}) : (f32, f32) -> f32
145+
%5 = call float @llvm.atan2.f32(float %0, float %1)
146+
; CHECK: llvm.intr.atan2(%{{.*}}, %{{.*}}) : (vector<8xf32>, vector<8xf32>) -> vector<8xf32>
147+
%6 = call <8 x float> @llvm.atan2.v8f32(<8 x float> %2, <8 x float> %3)
148+
ret void
149+
}
142150
; CHECK-LABEL: llvm.func @hyperbolic_trig_test
143151
define void @hyperbolic_trig_test(float %0, <8 x float> %1) {
144152
; CHECK: llvm.intr.sinh(%{{.*}}) : (f32) -> f32

mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ llvm.func @inv_trig_test(%arg0: f32, %arg1: vector<8xf32>) {
142142
llvm.return
143143
}
144144

145+
// CHECK-LABEL: @atan2_test
146+
llvm.func @atan2_test(%arg0: f32, %arg1: f32, %arg2: vector<8xf32>, %arg3: vector<8xf32>) {
147+
// CHECK: call float @llvm.atan2.f32
148+
"llvm.intr.atan2"(%arg0, %arg1) : (f32, f32) -> f32
149+
// CHECK: call <8 x float> @llvm.atan2.v8f32
150+
"llvm.intr.atan2"(%arg2, %arg3) : (vector<8xf32>, vector<8xf32>) -> vector<8xf32>
151+
llvm.return
152+
}
153+
145154
// CHECK-LABEL: @hyperbolic_trig_test
146155
llvm.func @hyperbolic_trig_test(%arg0: f32, %arg1: vector<8xf32>) {
147156
// CHECK: call float @llvm.sinh.f32

0 commit comments

Comments
 (0)