-
Notifications
You must be signed in to change notification settings - Fork 243
Fix LoopMerge Instruction Placement #3277
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
base: main
Are you sure you want to change the base?
Conversation
Restarting CI with the new HEAD |
; This test verifies that OpLoopMerge instructions are properly placed as the second-to-last | ||
; instruction in their basic block, immediately preceding the branch instruction. | ||
|
||
; RUN: llvm-spirv %S/loopMerge.bc -o %t.spv |
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.
Please move .bc file content to the text and call llvm-as in the test before the translation.
; CHECK-SPIRV-TEXT: LoopMerge | ||
; CHECK-SPIRV-TEXT: BranchConditional |
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.
; CHECK-SPIRV-TEXT: LoopMerge | |
; CHECK-SPIRV-TEXT: BranchConditional | |
; CHECK-SPIRV-TEXT: LoopMerge | |
; CHECK-SPIRV-TEXT-NEXT: BranchConditional |
} else { | ||
// If there's no proper terminator, add at the end | ||
return addInstruction( | ||
new SPIRVLoopMerge(MergeBlock, ContinueTarget, LoopControl, | ||
LoopControlParameters, BB), | ||
BB); | ||
} |
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.
Probably clang-tidy will recommend to remove else as previous if terminates with return.
The SPIR-V specification requires that OpLoopMerge instructions must be placed as the second-to-last instruction in their basic block, immediately preceding the branch instruction (OpBranch or OpBranchConditional). The original implementation was not ensuring this correct placement, which could lead to SPIR-V validation failures.