intel: propagate constants to first source of 2-src instructions

Submitted by Iago Toral Quiroga on Feb. 27, 2019, 12:45 p.m.

Details

Reviewer None
Submitted Feb. 27, 2019, 12:45 p.m.
Last Updated March 4, 2019, 12:15 p.m.
Revision 2

Cover Letter(s)

Revision 1
      This little series lives on top of my VK_KHR_shader_float16_int8 branch, since
it depends on having a more flexible combine constants pass, which is included
with that work.

A branch with that on this series is available here:
https://github.com/Igalia/mesa/tree/itoral/VK_KHR_shader_float16_int8_combine_constants

Shader-db results on KBL:

total instructions in shared programs: 14965607 -> 14855983 (-0.73%)
instructions in affected programs: 3988102 -> 3878478 (-2.75%)
helped: 14292
HURT: 59

total cycles in shared programs: 344324295 -> 340656008 (-1.07%)
cycles in affected programs: 247527740 -> 243859453 (-1.48%)
helped: 14056
HURT: 3314

total loops in shared programs: 4283 -> 4283 (0.00%)
loops in affected programs: 0 -> 0
helped: 0
HURT: 0

total spills in shared programs: 27812 -> 24350 (-12.45%)
spills in affected programs: 24921 -> 21459 (-13.89%)
helped: 345
HURT: 19

total fills in shared programs: 24173 -> 22032 (-8.86%)
fills in affected programs: 21124 -> 18983 (-10.14%)
helped: 355
HURT: 25

LOST:   0
GAINED: 5

Initially the series included propagation to BFE, BFI2 and BFREV, but that
actually led to significantly worse shader-db results, so that part has been
removed.

Iago

Iago Toral Quiroga (3):
  intel/compiler: allow constant propagation for int quotient and
    reminder
  intel/compiler: allow constant propagation to first source of 2-src
    instructions
  intel/compiler: implement more algebraic optimizations

 src/intel/compiler/brw_fs.cpp                 | 203 +++++++++++++++++-
 .../compiler/brw_fs_combine_constants.cpp     |  39 +++-
 .../compiler/brw_fs_copy_propagation.cpp      |  59 +++--
 3 files changed, 253 insertions(+), 48 deletions(-)
    
Revision 2
      This v2 addresses comments to v1, specifically constant folding of SHR/SHL
instructions now only take up to 5-bits from the shift count parameter, just
like the hardware does.

Also, patch 2 has been fixed to avoid hitting assertions that would then be
fixed by patch 3. I sent the series up to patch 2 to Jenkins and verified that
it came back green.

Iago Toral Quiroga (3):
  intel/compiler: allow constant propagation for int quotient and
    reminder
  intel/compiler: allow constant propagation to first source of 2src
    instructions
  intel/compiler: implement more algebraic optimizations

 src/intel/compiler/brw_fs.cpp                 | 203 +++++++++++++++++-
 .../compiler/brw_fs_combine_constants.cpp     |  39 +++-
 .../compiler/brw_fs_copy_propagation.cpp      |  59 +++--
 3 files changed, 253 insertions(+), 48 deletions(-)
    

Revisions