-
Notifications
You must be signed in to change notification settings - Fork 14.5k
[DXIL] Implement log intrinsic Lowering #86569
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
; RUN: opt -S -dxil-intrinsic-expansion < %s | FileCheck %s | ||
|
||
; Make sure dxil operation function calls for log are generated for float and half. | ||
|
||
; CHECK-LABEL: log_float4 | ||
; CHECK: call <4 x float> @llvm.log2.v4f32(<4 x float> %{{.*}}) | ||
; CHECK: fmul <4 x float> <float 0x3FE62E4300000000, float 0x3FE62E4300000000, float 0x3FE62E4300000000, float 0x3FE62E4300000000>, %{{.*}} | ||
define noundef <4 x float> @log_float4(<4 x float> noundef %p0) { | ||
entry: | ||
%p0.addr = alloca <4 x float>, align 16 | ||
store <4 x float> %p0, ptr %p0.addr, align 16 | ||
%0 = load <4 x float>, ptr %p0.addr, align 16 | ||
%elt.log = call <4 x float> @llvm.log.v4f32(<4 x float> %0) | ||
ret <4 x float> %elt.log | ||
} | ||
|
||
; CHECK-LABEL: log10_float4 | ||
; CHECK: call <4 x float> @llvm.log2.v4f32(<4 x float> %{{.*}}) | ||
; CHECK: fmul <4 x float> <float 0x3FD3441340000000, float 0x3FD3441340000000, float 0x3FD3441340000000, float 0x3FD3441340000000>, %{{.*}} | ||
define noundef <4 x float> @log10_float4(<4 x float> noundef %p0) { | ||
entry: | ||
%p0.addr = alloca <4 x float>, align 16 | ||
store <4 x float> %p0, ptr %p0.addr, align 16 | ||
%0 = load <4 x float>, ptr %p0.addr, align 16 | ||
%elt.log10 = call <4 x float> @llvm.log10.v4f32(<4 x float> %0) | ||
ret <4 x float> %elt.log10 | ||
} | ||
|
||
declare <4 x float> @llvm.log.v4f32(<4 x float>) | ||
declare <4 x float> @llvm.log10.v4f32(<4 x float>) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
; RUN: opt -S -dxil-intrinsic-expansion < %s | FileCheck %s --check-prefixes=CHECK,EXPCHECK | ||
; RUN: opt -S -dxil-op-lower < %s | FileCheck %s --check-prefixes=CHECK,DOPCHECK | ||
|
||
; Make sure dxil operation function calls for log are generated. | ||
|
||
define noundef float @log_float(float noundef %a) #0 { | ||
entry: | ||
; DOPCHECK: call float @dx.op.unary.f32(i32 23, float %{{.*}}) | ||
; EXPCHECK: call float @llvm.log2.f32(float %a) | ||
; CHECK: fmul float 0x3FE62E4300000000, %{{.*}} | ||
%elt.log = call float @llvm.log.f32(float %a) | ||
ret float %elt.log | ||
} | ||
|
||
define noundef half @log_half(half noundef %a) #0 { | ||
entry: | ||
; DOPCHECK: call half @dx.op.unary.f16(i32 23, half %{{.*}}) | ||
; EXPCHECK: call half @llvm.log2.f16(half %a) | ||
; CHECK: fmul half 0xH398C, %{{.*}} | ||
%elt.log = call half @llvm.log.f16(half %a) | ||
ret half %elt.log | ||
} | ||
|
||
declare half @llvm.log.f16(half) | ||
declare float @llvm.log.f32(float) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
; RUN: opt -S -dxil-intrinsic-expansion < %s | FileCheck %s --check-prefixes=CHECK,EXPCHECK | ||
; RUN: opt -S -dxil-op-lower < %s | FileCheck %s --check-prefixes=CHECK,DOPCHECK | ||
|
||
; Make sure dxil operation function calls for log10 are generated. | ||
|
||
define noundef float @log10_float(float noundef %a) #0 { | ||
entry: | ||
; DOPCHECK: call float @dx.op.unary.f32(i32 23, float %{{.*}}) | ||
; EXPCHECK: call float @llvm.log2.f32(float %a) | ||
; CHECK: fmul float 0x3FD3441340000000, %{{.*}} | ||
%elt.log10 = call float @llvm.log10.f32(float %a) | ||
ret float %elt.log10 | ||
} | ||
|
||
define noundef half @log10_half(half noundef %a) #0 { | ||
entry: | ||
; DOPCHECK: call half @dx.op.unary.f16(i32 23, half %{{.*}}) | ||
; EXPCHECK: call half @llvm.log2.f16(half %a) | ||
; CHECK: fmul half 0xH34D1, %{{.*}} | ||
%elt.log10 = call half @llvm.log10.f16(half %a) | ||
ret half %elt.log10 | ||
} | ||
|
||
declare half @llvm.log10.f16(half) | ||
declare float @llvm.log10.f32(float) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 log2 are generated for float and half. | ||
|
||
define noundef float @log2_float(float noundef %a) #0 { | ||
entry: | ||
; CHECK:call float @dx.op.unary.f32(i32 23, float %{{.*}}) | ||
%elt.log2 = call float @llvm.log2.f32(float %a) | ||
ret float %elt.log2 | ||
} | ||
|
||
define noundef half @log2_half(half noundef %a) #0 { | ||
entry: | ||
; CHECK:call half @dx.op.unary.f16(i32 23, half %{{.*}}) | ||
%elt.log2 = call half @llvm.log2.f16(half %a) | ||
ret half %elt.log2 | ||
} | ||
|
||
declare half @llvm.log2.f16(half) | ||
declare float @llvm.log2.f32(float) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 log2 does not support double overload type | ||
; CHECK: LLVM ERROR: Invalid Overload Type | ||
|
||
define noundef double @log2_double(double noundef %a) { | ||
entry: | ||
%elt.log2 = call double @llvm.log2.f64(double %a) | ||
ret double %elt.log2 | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.