[llvm] [SPIR-V] Erase all instructions after OpKill, not just the next one (PR #219022)
Arseniy Obolenskiy via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 28 01:47:11 PDT 2026
================
@@ -47,6 +47,32 @@ end: ; preds = %lt0, %entry
}
declare void @llvm.spv.discard()
+define void @test_scalar_multi_instr_after_discard(float noundef %Buf, ptr %Out) {
+entry:
+; CHECK-LABEL: ; -- Begin function test_scalar_multi_instr_after_discard
+; CHECK: OpBranchConditional %[[#]] %[[#truel:]] %[[#endl:]]
+; CHECK: %[[#truel]] = OpLabel
+; SPIRV15: OpKill
+; SPIRV15-NOT: OpStore
+; SPIRV16: OpDemoteToHelperInvocation
+; SPIRV16: OpBranch %[[#endl]]
+; CHECK: %[[#endl]] = OpLabel
+ %Buf.addr = alloca float, align 4
+ store float %Buf, ptr %Buf.addr, align 4
+ %1 = load float, ptr %Buf.addr, align 4
+ %2 = fcmp olt float %1, 0.000000e+00
+ br i1 %2, label %lt0, label %end
+
+lt0: ; preds = %entry
+ call void @llvm.spv.discard()
+ store volatile float 1.0, ptr %Out, align 4
+ store volatile float 2.0, ptr %Out, align 4
----------------
aobolensk wrote:
There are no def-use chains, IIRC. so that should be safe on MIR level
https://github.com/llvm/llvm-project/pull/219022
More information about the llvm-commits
mailing list