[llvm] f193d19 - [SPIR-V] Fix OpDecorate insertion point for non-PHI defs in decorateUsesAsNonUniform (#212524)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 29 00:48:04 PDT 2026
Author: Arseniy Obolenskiy
Date: 2026-07-29T09:48:00+02:00
New Revision: f193d19d2127023966cbeb6ccf1487f975f53acc
URL: https://github.com/llvm/llvm-project/commit/f193d19d2127023966cbeb6ccf1487f975f53acc
DIFF: https://github.com/llvm/llvm-project/commit/f193d19d2127023966cbeb6ccf1487f975f53acc.diff
LOG: [SPIR-V] Fix OpDecorate insertion point for non-PHI defs in decorateUsesAsNonUniform (#212524)
Inserting before the defining instruction placed the decoration ahead of
its own operand, breaking dominance for the loop-carried case
Fix machine code errors from
https://github.com/llvm/llvm-project/pull/208224#issuecomment-5095074660
Added:
Modified:
llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
llvm/test/CodeGen/SPIRV/hlsl-resources/NonUniformIdx/RWBufferNonUniformIdxLoop.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
index c8f705e0251b6..a45a978b5d11e 100644
--- a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
@@ -6452,7 +6452,8 @@ void SPIRVInstructionSelector::decorateUsesAsNonUniform(
if (!IsDecorated) {
MachineBasicBlock &MBB = *DefMI->getParent();
- MachineInstr &InsertPt = DefMI->isPHI() ? *MBB.getFirstNonPHI() : *DefMI;
+ MachineInstr &InsertPt =
+ DefMI->isPHI() ? *MBB.getFirstNonPHI() : *DefMI->getNextNode();
buildOpDecorate(CurrentReg, InsertPt, TII,
SPIRV::Decoration::NonUniformEXT, {});
}
diff --git a/llvm/test/CodeGen/SPIRV/hlsl-resources/NonUniformIdx/RWBufferNonUniformIdxLoop.ll b/llvm/test/CodeGen/SPIRV/hlsl-resources/NonUniformIdx/RWBufferNonUniformIdxLoop.ll
index e9dda9e94515c..ca892fefd3af4 100644
--- a/llvm/test/CodeGen/SPIRV/hlsl-resources/NonUniformIdx/RWBufferNonUniformIdxLoop.ll
+++ b/llvm/test/CodeGen/SPIRV/hlsl-resources/NonUniformIdx/RWBufferNonUniformIdxLoop.ll
@@ -1,4 +1,4 @@
-; RUN: llc -O0 -mtriple=spirv1.6-unknown-vulkan1.3-compute %s -o - | FileCheck %s
+; RUN: llc -O0 -mtriple=spirv1.6-unknown-vulkan1.3-compute -verify-machineinstrs %s -o - | FileCheck %s
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv1.6-unknown-vulkan1.3-compute %s -o - -filetype=obj | spirv-val %}
; A non-uniform index carried across a loop through a phi creates an SSA cycle
More information about the llvm-commits
mailing list