-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[HLSL] [DirectX] translate llvm fast math flags to llvm 3.7 fast math flags #122025
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
; RUN: llc %s --filetype=obj -o - | dxil-dis -o - | FileCheck %s | ||
target triple = "dxil-unknown-shadermodel6.7-library" | ||
|
||
define float @fma(float %0, float %1, float %2) #0 { | ||
; verify reassoc and contract are converted to fast | ||
; CHECK: %4 = fmul fast float %0, %1 | ||
%4 = fmul reassoc float %0, %1 | ||
; CHECK-NEXT: %5 = fadd fast float %4, %2 | ||
%5 = fadd contract float %4, %2 | ||
; verify these are converted to a single fast flag | ||
; CHECK-NEXT: %6 = fmul fast float %0, %1 | ||
%6 = fmul reassoc contract float %0, %1 | ||
; verify these flags are maintained | ||
; CHECK-NEXT: %7 = fadd nnan ninf nsz arcp float %0, %1 | ||
%7 = fadd nnan ninf nsz arcp float %0, %1 | ||
; verify that afn is removed | ||
; CHECK-NEXT: %8 = fmul float %0, %1 | ||
%8 = fmul afn float %0, %1 | ||
ret float %5 | ||
} | ||
|
||
attributes #0 = { norecurse nounwind readnone willreturn "disable-tail-calls"="false" "waveops-include-helper-lanes" "fp32-denorm-mode"="any" "hlsl.export" } | ||
|
Oops, something went wrong.
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.
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.
Why is "approx func" removed?
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.
https://releases.llvm.org/3.7.1/docs/LangRef.html#fast-math-flags
Not listed in fast math flags for 3.7, is this an error?
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.
Ah, good point... I don't want to stand in the way of this getting in, but neither is "AllowContract". Should we be asserting on these instead? (it seems "UnsafeAlgebra" was just renamed to "AllowReassoc")
https://github.com/microsoft/DirectXShaderCompiler/blob/070d0d5a2beacef9eeb51037a9b04665716fd6f3/include/llvm/IR/Operator.h#L171
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.
@llvm-beanz thoughts on this?
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.
ApproxFunc has no equivalent in LLVM 3.7 so there is no bitcode representation of it. We have no choice but to drop it.
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.
Also, in LLVM 3.7 UnsafeAlgebra was a magic catch all flag for "all things fast", it was separated out into granular flags in this commit - 629c41153876b.
It had the impact in the LLVM 3.7 optimizer of controlling both contraction and reassociation (to the extent that LLVM 3.7 had optimizations).