[Mlir-commits] [mlir] 403b7b6 - [MLIR][LLVMIR] Add support for atan2 intrinsics op (#127970)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Feb 27 10:23:27 PST 2025


Author: Letu Ren
Date: 2025-02-27T10:23:23-08:00
New Revision: 403b7b66dea33a073c365d7ae9fb07da4844eb62

URL: https://github.com/llvm/llvm-project/commit/403b7b66dea33a073c365d7ae9fb07da4844eb62
DIFF: https://github.com/llvm/llvm-project/commit/403b7b66dea33a073c365d7ae9fb07da4844eb62.diff

LOG: [MLIR][LLVMIR] Add support for atan2 intrinsics op (#127970)

This is similar to https://github.com/llvm/llvm-project/pull/127317

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
    mlir/test/Target/LLVMIR/Import/intrinsic.ll
    mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
index c270b0898f865..aa6551eb43fa6 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -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">;

diff  --git a/mlir/test/Target/LLVMIR/Import/intrinsic.ll b/mlir/test/Target/LLVMIR/Import/intrinsic.ll
index 569b0def37856..d14fc8a5942ca 100644
--- a/mlir/test/Target/LLVMIR/Import/intrinsic.ll
+++ b/mlir/test/Target/LLVMIR/Import/intrinsic.ll
@@ -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

diff  --git a/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir b/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
index 3616a2e3c7b21..0b47163cc51d3 100644
--- a/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir
@@ -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


        


More information about the Mlir-commits mailing list