KhronosGroup / KhronosGroup/SPIRV-Tools

reduce: idea: consider aggressively removing dead code

Open
#2,502 0 comments 0 reactions 1 assignee Claimed by @kuhar View on GitHub
component:reducer
Dominant language
C++
Stars
1.4k
Forks
709
Avg merge
1d 22h
Merged PRs (30d)
28

Description

Dead code can be tricky to reduce correctly because the rules of valid SPIR-V currently use dominance information. Most tools and compilers probably ignore dead code anyway. We could try removing all dead code initially to see if the initial state is still interesting and, if so, remove all dead code after each pass. This can also avoid the reducer making a bad decision. For example, consider a shader that has a reachable block that causes a compiler crash.

* No dead code elimination:
* The reducer makes the interesting block unreachable and the compiler somehow still crashes.
* The reducer now might not be able to simplify this code because it will give up in many cases if the code is unreachable.
* Dead code elimination:
* The reducer makes the interesting block unreachable and it is removed.
* The shader no longer causes a crash and so is deemed uninteresting; the reducer will backtrack and the interesting block will remain reachable and will continue to be simplified.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.