glsl: Optimize "if (cond) discard;" to a conditional discard.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 23 Oct 2014 03:48:21 +0000 (20:48 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 24 Feb 2015 23:24:53 +0000 (15:24 -0800)
commit30f51f1a1a70bc838d5bed449daff0dd9f2e8ef2
treef3a5cc8ca132aa63e1c5d112f2bfb500cd8e7f77
parent8eb6c109994de2827b0a1340a2dc8d933edaf5e0
glsl: Optimize "if (cond) discard;" to a conditional discard.

st_glsl_to_tgsi and ir_to_mesa have handled conditional discards for a
long time; the previous patch added that capability to i965.

i965 (Haswell) shader-db stats:

Without NIR:
total instructions in shared programs: 5792133 -> 5776360 (-0.27%)
instructions in affected programs:     737585 -> 721812 (-2.14%)
helped:                                6300
HURT:                                  68
GAINED:                                2

With NIR:
total instructions in shared programs: 5787538 -> 5769569 (-0.31%)
instructions in affected programs:     767843 -> 749874 (-2.34%)
helped:                                6522
HURT:                                  35
GAINED:                                6

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/glsl/Makefile.sources
src/glsl/glsl_parser_extras.cpp
src/glsl/ir_optimization.h
src/glsl/opt_conditional_discard.cpp [new file with mode: 0644]