-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[DirectX] Add trig intrinsics and link them with DXIL backend #95968
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 acos are generated for float and half. | ||
|
||
define noundef float @tan_float(float noundef %a) { | ||
entry: | ||
; CHECK:call float @dx.op.unary.f32(i32 15, float %{{.*}}) | ||
%elt.acos = call float @llvm.acos.f32(float %a) | ||
ret float %elt.acos | ||
} | ||
|
||
define noundef half @tan_half(half noundef %a) { | ||
entry: | ||
; CHECK:call half @dx.op.unary.f16(i32 15, half %{{.*}}) | ||
%elt.acos = call half @llvm.acos.f16(half %a) | ||
ret half %elt.acos | ||
} | ||
|
||
declare half @llvm.acos.f16(half) | ||
declare float @llvm.acos.f32(float) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we have test cases with vectors too? We are not consistent - some intrinsics have vector tests in this folder and some do not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A change is needed in the dxil backend to scalarize vectors. We don’t have support for that yet, so we can’t test it. The only exceptions to this are dot product and the instruction expansion pass test cases. |
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 acos does not support double overload type | ||
; CHECK: LLVM ERROR: Invalid Overload | ||
|
||
define noundef double @acos_double(double noundef %a) { | ||
entry: | ||
%1 = call double @llvm.acos.f64(double %a) | ||
ret double %1 | ||
} |
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 asin are generated for float and half. | ||
|
||
define noundef float @tan_float(float noundef %a) { | ||
entry: | ||
; CHECK:call float @dx.op.unary.f32(i32 16, float %{{.*}}) | ||
%elt.asin = call float @llvm.asin.f32(float %a) | ||
ret float %elt.asin | ||
} | ||
|
||
define noundef half @tan_half(half noundef %a) { | ||
entry: | ||
; CHECK:call half @dx.op.unary.f16(i32 16, half %{{.*}}) | ||
%elt.asin = call half @llvm.asin.f16(half %a) | ||
ret half %elt.asin | ||
} | ||
|
||
declare half @llvm.asin.f16(half) | ||
declare float @llvm.asin.f32(float) |
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 asin does not support double overload type | ||
; CHECK: LLVM ERROR: Invalid Overload | ||
|
||
define noundef double @asin_double(double noundef %a) { | ||
entry: | ||
%1 = call double @llvm.asin.f64(double %a) | ||
ret double %1 | ||
} |
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 atan are generated for float and half. | ||
|
||
define noundef float @tan_float(float noundef %a) { | ||
entry: | ||
; CHECK:call float @dx.op.unary.f32(i32 17, float %{{.*}}) | ||
%elt.atan = call float @llvm.atan.f32(float %a) | ||
ret float %elt.atan | ||
} | ||
|
||
define noundef half @tan_half(half noundef %a) { | ||
entry: | ||
; CHECK:call half @dx.op.unary.f16(i32 17, half %{{.*}}) | ||
%elt.atan = call half @llvm.atan.f16(half %a) | ||
ret half %elt.atan | ||
} | ||
|
||
declare half @llvm.atan.f16(half) | ||
declare float @llvm.atan.f32(float) |
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 atan does not support double overload type | ||
; CHECK: LLVM ERROR: Invalid Overload | ||
|
||
define noundef double @atan_double(double noundef %a) { | ||
entry: | ||
%1 = call double @llvm.atan.f64(double %a) | ||
ret double %1 | ||
} |
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 cosh are generated for float and half. | ||
|
||
define noundef float @tan_float(float noundef %a) { | ||
entry: | ||
; CHECK:call float @dx.op.unary.f32(i32 18, float %{{.*}}) | ||
%elt.cosh = call float @llvm.cosh.f32(float %a) | ||
ret float %elt.cosh | ||
} | ||
|
||
define noundef half @tan_half(half noundef %a) { | ||
entry: | ||
; CHECK:call half @dx.op.unary.f16(i32 18, half %{{.*}}) | ||
%elt.cosh = call half @llvm.cosh.f16(half %a) | ||
ret half %elt.cosh | ||
} | ||
|
||
declare half @llvm.cosh.f16(half) | ||
declare float @llvm.cosh.f32(float) |
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 cosh does not support double overload type | ||
; CHECK: LLVM ERROR: Invalid Overload | ||
|
||
define noundef double @cosh_double(double noundef %a) { | ||
entry: | ||
%1 = call double @llvm.cosh.f64(double %a) | ||
ret double %1 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
llvm.asin.f16
intentionally excluded here and everywhere else below?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. f16 is a target specific intrinsic. So there won’t be any general documentation for it.