Skip to content

spirv-opt improper inlining OpKill into continue construct #2433

@programmerjake

Description

@programmerjake

@alan-baker asked me to open this issue here from KhronosGroup/SPIRV-Headers#86

Original issue:
Is a continue construct that consists of OpKill valid? If so, the rules on the header block post-dominating the continue construct need to be fixed. Otherwise, there's a bug in spirv-opt where kill() is improperly inlined.

http://shader-playground.timjones.io/1323167d9be3ec6d7a54996e098612de

spirv-opt output:

; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 7
; Bound: 13
; Schema: 0
               OpCapability Shader
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint Fragment %main "main"
               OpExecutionMode %main OriginUpperLeft
               OpSource GLSL 330
               OpName %main "main"
       %void = OpTypeVoid
          %3 = OpTypeFunction %void
       %main = OpFunction %void None %3
          %5 = OpLabel
               OpLoopMerge %11 %12 None
               OpBranch %12
         %12 = OpLabel
               OpKill
         %11 = OpLabel
               OpUnreachable
               OpFunctionEnd

spirv-opt input:

// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 17

                              Capability Shader
               1:             ExtInstImport  "GLSL.std.450"
                              MemoryModel Logical GLSL450
                              EntryPoint Fragment 4  "main"
                              ExecutionMode 4 OriginUpperLeft
                              Source GLSL 330
                              Name 4  "main"
                              Name 6  "kill("
               2:             TypeVoid
               3:             TypeFunction 2
              14:             TypeBool
              15:    14(bool) ConstantTrue
         4(main):           2 Function None 3
               5:             Label
                              Branch 9
               9:             Label
                              LoopMerge 11 12 None
                              Branch 13
              13:             Label
                              BranchConditional 15 10 11
              10:               Label
                                Branch 12
              12:               Label
              16:           2   FunctionCall 6(kill()
                                Branch 9
              11:             Label
                              Return
                              FunctionEnd
        6(kill():           2 Function None 3
               7:             Label
                              Kill
                              FunctionEnd

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions