-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SPIR-V] Support SPV_INTEL_fp_max_error extension for !fpmath
metadata
#130619
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
5 commits
Select commit
Hold shift + click to select a range
f9fa4d8
[SPIR-V] Support SPV_INTEL_fp_max_error extension for `!fpmath` metadata
vmaksimo fe4d37b
"fix doc"
vmaksimo cc12995
Update llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
vmaksimo 5921476
Update IntelFPMaxErrorFPMath.ll
vmaksimo a5fb869
Merge branch 'main' into SPV_INTEL_fp_max_error
vmaksimo 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
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
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
32 changes: 32 additions & 0 deletions
32
llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_fp_max_error/IntelFPMaxErrorFPMath.ll
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,32 @@ | ||
; Confirm that we handle fpmath metadata correctly | ||
; This is a copy of https://github.com/KhronosGroup/SPIRV-LLVM-Translator/blob/main/test/extensions/INTEL/SPV_INTEL_fp_max_error/IntelFPMaxErrorFPMath.ll | ||
|
||
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=+SPV_INTEL_fp_max_error %s -o %t.spt | ||
; RUN: FileCheck %s --input-file=%t.spt | ||
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=+SPV_INTEL_fp_max_error %s -o - -filetype=obj | spirv-val %} | ||
|
||
; CHECK: OpCapability FPMaxErrorINTEL | ||
; CHECK: OpExtension "SPV_INTEL_fp_max_error" | ||
|
||
; CHECK: OpName %[[#CalleeName:]] "callee" | ||
; CHECK: OpName %[[#F3:]] "f3" | ||
; CHECK: OpDecorate %[[#F3]] FPMaxErrorDecorationINTEL 1075838976 | ||
; CHECK: OpDecorate %[[#Callee:]] FPMaxErrorDecorationINTEL 1065353216 | ||
|
||
; CHECK: %[[#FloatTy:]] = OpTypeFloat 32 | ||
; CHECK: %[[#Callee]] = OpFunctionCall %[[#FloatTy]] %[[#CalleeName]] | ||
|
||
define float @callee(float %f1, float %f2) { | ||
entry: | ||
ret float %f1 | ||
} | ||
|
||
define void @test_fp_max_error_decoration(float %f1, float %f2) { | ||
entry: | ||
%f3 = fdiv float %f1, %f2, !fpmath !0 | ||
call float @callee(float %f1, float %f2), !fpmath !1 | ||
ret void | ||
} | ||
|
||
!0 = !{float 2.500000e+00} | ||
!1 = !{float 1.000000e+00} |
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.
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 it necessary to create a new intrinsic? I have a feeling, that this functionality can be added in
handleMIFlagDecoration
function. (if it's possible) by casting instruction to FPMathOperator and calling getFPAccuracy.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.
I believe FP-Math flags are not the same as
!fpmath
metadata. I've added intrinsic to support the second case, but we can extend the extension usage to support your case too (we didn't have such support in Khronos though)Uh oh!
There was an error while loading. Please reload this page.
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.
But it is, see: https://llvm.org/doxygen/Instructions_8cpp_source.html#l02682
A valid point would be: llvm ir instruction != mir instruction, so API I'm referring above is not applicable. Yet during my recent work on aliasing metadata I've found, that information from aliasing metadata is being transferred to
MachineMemOperand
class and I can access this information in the backend by callinggetAAInfo
. I'm not sure, if it will work, as I'm still a novice in LLVM backend, yet I do seeMO_FPImmediate
enum amongMachineOperandType
class. Can we check, that it (or some other machine operand subclass) doesn't store accuracy information?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.
I like the idea, but it seems that we can't do that -
handleMIFlagDecoration
is "too late" in the stack, and we don't have FP accuracy saved in BE machine instructions.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.
I'll unresolve the thread just in case if other reviewers have something to say