i965: Handle CMP.nz ... 0 and MOV.nz similarly in cmod propagation.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 24 Jan 2015 12:16:54 +0000 (04:16 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Mon, 26 Jan 2015 18:13:18 +0000 (10:13 -0800)
commit9f5fee880470a7e317aad35d4521cd525714455f
tree572b488c2d90b32f760d3bdaa0d828f97f96474b
parent9cbb9165b9454ccc7f2a6702ce71bc5cd9faba02
i965: Handle CMP.nz ... 0 and MOV.nz similarly in cmod propagation.

"MOV.nz null src" and "CMP.nz null src 0" are equivalent instructions.

Previously, we deleted MOV.nz instructions when the instruction
generating the MOV's source also wrote the flag register (as the flag
register already contains the desired value).  However, we wouldn't
delete CMP.nz instructions that served the same purpose.

We also didn't attempt true cmod propagation on MOV.nz instructions,
while we would for the equivalent CMP.nz form.

This patch fixes both limitations, treating both forms equally.
CMP.nz instructions will now be deleted (helping the NIR backend),
and MOV.nz instructions will have their .nz propagated.

No changes in shader-db without NIR.  With NIR,

total instructions in shared programs: 6006153 -> 5969364 (-0.61%)
instructions in affected programs:     2087139 -> 2050350 (-1.76%)
helped:                                10704
HURT:                                  0
GAINED:                                2
LOST:                                  2

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/i965/brw_fs_cmod_propagation.cpp