KhronosGroup / SPIRV-Tools

Apache License 2.0
1.04k stars 545 forks source link

spirv-opt (with various flags) generates code that spirv-val rejects: "Loop header is targeted by 0 back-edge blocks but the standard requires exactly one" #2452

Closed afd closed 5 years ago

afd commented 5 years ago

Files to reproduce the problem

glsl_reduced.frag is a minimized GLSL shader. When compiled to SPIR-V with glslangValidator we get glsl_reduced.spv. This has been further reduced using spirv-reduce to spiv_reduced.spv.

Doing:

spirv-opt --redundancy-elimination --copy-propagate-arrays --merge-blocks --ccp --simplify-instructions --convert-local-access-chains --eliminate-dead-code-aggr essive --eliminate-local-single-block --if-conversion --convert-local-access-cha ins --eliminate-dead-branches --merge-return --scalar-replacement=100 --eliminat e-local-multi-store spirv_reduced.spv -o temp.spv

spirv-val temp.spv

should trigger the problem.

I did not try to reduce the spirv-opt flags, in case (as with #2450) there may be an issue both with the optimizer generating invalid code and the validator not picking this up soon enough.

alan-baker commented 5 years ago

Appears to be dead branch elimination.