DeadInsertElim: Detect and DCE dead Inserts
authorGreg Fischer <greg@lunarg.com>
Thu, 11 Jan 2018 23:23:58 +0000 (16:23 -0700)
committerSteven Perron <stevenperron@google.com>
Thu, 25 Jan 2018 21:07:21 +0000 (16:07 -0500)
commit684997eb7233fd6ad1a6ab52216f2a973003dd70
tree025b228bc888e17f70c8a48ba6d404b4b68f400a
parent2e93e806e454e2cfefabf217320038188c6c1fb6
DeadInsertElim: Detect and DCE dead Inserts

This adds Dead Insert Elimination to the end of the
--eliminate-insert-extract pass. See the new tests for examples of code
that will benefit.

Essentially, this removes OpCompositeInsert instructions which are not
used, either because there is no instruction which uses the value at the
index it is inserted, or because a subsequent insert intercepts any such
use.

This code has been seen to remove significant amounts of dead code from
real-life HLSL shaders being ported to Vulkan. In fact, it is needed to
remove dead texture samples which cause Vulkan validation layer errors
(unbound textures and samplers) if not removed . Such DCE is thus
required for fxc equivalence and legalization.

This analysis operates across "chains" of Inserts which can also contain
Phi instructions.
source/opt/insert_extract_elim.cpp
source/opt/insert_extract_elim.h
test/opt/insert_extract_elim_test.cpp