[Mesa-dev] [PATCH 00/12] i965/vec4: Better dead code elimination.

Matt Turner mattst88 at gmail.com
Tue Mar 18 20:23:21 PDT 2014


total instructions in shared programs: 811813 -> 788004 (-2.93%)
instructions in affected programs:     185685 -> 161876 (-12.82%)
(this is only the .shader_test files. Our .vert files are useless)

This series improves the dead code elimination pass in i965
vec4 backend. A small overview of the patches:

i965/vec4: Add missing doxygen close brace.
i965/vec4: Add and use vec4_instruction::writes_flag().
i965/vec4: Rename depends_on_flags() to reads_flag().
i965/vec4: Print the predicate in dump_instructions().
i965/vec4: Add is_null() method to dst_reg.
i965/vec4: Preparatory clean up of dead_code_eliminate().

   Clean ups and preparations.

i965/vec4: Don't dead code eliminate instructions

   Remove the possibility of eliminating things that
   weren't actually dead.

i965/vec4: Track live ranges per-channel, not per vgrf.
i965/vec4: Let dead code eliminate trim dead channels.

   Perform dead code elimination on a per-channel basis.

i965/vec4: Factor code out of DCE into a separate
i965/vec4: Eliminate writes that are never read.

   For each instruction, eliminate previous instructions
   whose results this instruction overwrote before they
   were read.

i965/vec4: Eliminate dead writes to the flag register.

   Same thing, but for the flag register.

The dead code elimination pass still has some limitations
and areas for improvement. I'm pretty sick of working on
this, so I'm not planning to do it anytime soon. Ideas:

 - Extend the pass to eliminate overwritten results in all
   basic blocks (currently we only do it in the first block)
 - Search instructions backwards, so that when we eliminate
   dead writes we don't have to consider them again.
 - Stop scanning backwards if we hit the beginning of the
   destination's live range.


More information about the mesa-dev mailing list