Skip to content
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

[DXIL] Add tan intrinsic part 2 #90277

Merged
merged 1 commit into from
May 8, 2024
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
3 changes: 3 additions & 0 deletions llvm/lib/Target/DirectX/DXIL.td
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ def Cos : DXILOpMapping<12, unary, int_cos,
def Sin : DXILOpMapping<13, unary, int_sin,
"Returns sine(theta) for theta in radians.",
[llvm_halforfloat_ty, LLVMMatchType<0>]>;
def Tan : DXILOpMapping<14, unary, int_tan,
"Returns tangent(theta) for theta in radians.",
[llvm_halforfloat_ty, LLVMMatchType<0>]>;
def Exp2 : DXILOpMapping<21, unary, int_exp2,
"Returns the base 2 exponential, or 2**x, of the specified value."
"exp2(x) = 2**x.",
Expand Down
20 changes: 20 additions & 0 deletions llvm/test/CodeGen/DirectX/tan.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; RUN: opt -S -dxil-op-lower < %s | FileCheck %s

; Make sure dxil operation function calls for tan are generated for float and half.

define noundef float @tan_float(float noundef %a) #0 {
entry:
; CHECK:call float @dx.op.unary.f32(i32 14, float %{{.*}})
%elt.tan = call float @llvm.tan.f32(float %a)
ret float %elt.tan
}

define noundef half @tan_half(half noundef %a) #0 {
entry:
; CHECK:call half @dx.op.unary.f16(i32 14, half %{{.*}})
%elt.tan = call half @llvm.tan.f16(half %a)
ret half %elt.tan
}

declare half @llvm.tan.f16(half)
declare float @llvm.tan.f32(float)
10 changes: 10 additions & 0 deletions llvm/test/CodeGen/DirectX/tan_error.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; RUN: not opt -S -dxil-op-lower %s 2>&1 | FileCheck %s

; DXIL operation tan does not support double overload type
; CHECK: LLVM ERROR: Invalid Overload

define noundef double @tan_double(double noundef %a) #0 {
entry:
%1 = call double @llvm.tan.f64(double %a)
ret double %1
}
Loading