i965/fs: New peephole optimization to generate SEL.
authorMatt Turner <mattst88@gmail.com>
Wed, 23 Oct 2013 00:51:28 +0000 (17:51 -0700)
committerMatt Turner <mattst88@gmail.com>
Thu, 5 Dec 2013 04:05:44 +0000 (20:05 -0800)
commit13de9f03f177d3ae0921fded1a102b66130f8b40
treef1069e6f978e143efb3cc364581a8ba26cb72807
parentfa227e7cbca279cd70ea7028a33d520579385f9f
i965/fs: New peephole optimization to generate SEL.

fs_visitor::try_replace_with_sel optimizes only if statements whose
"then" and "else" bodies contain a single MOV instruction. It also
could not handle constant arguments, since they cause an extra MOV
immediate to be generated (since we haven't run constant propagation,
there are more than the single MOV).

This peephole fixes both of these and operates as a normal optimization
pass.

fs_visitor::try_replace_with_sel is still arguably necessary, since it
runs before pull constant loads are lowered.

total instructions in shared programs: 1559129 -> 1545833 (-0.85%)
instructions in affected programs:     167120 -> 153824 (-7.96%)
GAINED:                                13
LOST:                                  6

Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/Makefile.sources
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp [new file with mode: 0644]