On 17/10/18 8:49 pm, Bas Nieuwenhuizen wrote:
On Wed, Oct 17, 2018 at 5:49 AM Timothy Arceri <tarc...@itsqueeze.com> wrote:

For example:

    vec1 32 ssa_386 = feq ssa_333.x, ssa_6
    vec1 32 ssa_387 = feq ssa_333.x, ssa_2
    vec1 32 ssa_391 = bcsel ssa_387, ssa_388, ssa_324
    vec1 32 ssa_396 = bcsel ssa_386, ssa_324, ssa_391

Can be simplified to:

    vec1 32 ssa_386 = feq ssa_333.x, ssa_6
    vec1 32 ssa_391 = bcsel ssa_387, ssa_388, ssa_324

There are a bunch of these in Rise of The Tomb Raiders Vulkan
shaders. There are also a hadful of shaders helped in shader-db
but the changes there are smaller.

For RADV:

Totals from affected shaders:
SGPRS: 11184 -> 11168 (-0.14 %)
VGPRS: 11484 -> 11484 (0.00 %)
Spilled SGPRs: 1119 -> 1116 (-0.27 %)
Spilled VGPRs: 0 -> 0 (0.00 %)
Private memory VGPRs: 0 -> 0 (0.00 %)
Scratch size: 0 -> 0 (0.00 %) dwords per thread
Code Size: 1210856 -> 1210372 (-0.04 %) bytes
LDS: 0 -> 0 (0.00 %) blocks
Max Waves: 360 -> 360 (0.00 %)
Wait states: 0 -> 0 (0.00 %)
---
  src/compiler/nir/nir_opt_algebraic.py | 4 ++++
  1 file changed, 4 insertions(+)

diff --git a/src/compiler/nir/nir_opt_algebraic.py 
b/src/compiler/nir/nir_opt_algebraic.py
index cc747250ba5..7530710cbe0 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -34,6 +34,7 @@ a = 'a'
  b = 'b'
  c = 'c'
  d = 'd'
+e = 'e'

  # Written in the form (<search>, <replace>) where <search> is an expression
  # and <replace> is either an expression or a value.  An expression is
@@ -525,6 +526,9 @@ optimizations = [
     # The result of this should be hit by constant propagation and, in the
     # next round of opt_algebraic, get picked up by one of the above two.
     (('bcsel', '#a', b, c), ('bcsel', ('ine', 'a', 0), b, c)),
+   # Remove redundant bcsel
+   (('bcsel', ('ieq', '#a', b), c, ('bcsel', ('ieq', '#d', b), e, c)), 
('bcsel', ('ieq', d, b), e, c)),

I think this only works if the value of a is not equal to the value of
d? if a is equal to d, then the expression on the left is always c,
while the expression on the right is e sometimes?

Hmm. I though the search/matching code was smart enough to handle this, but looking at it it seems I was wrong.

I'll take a look tomorrow to see how hard it would be to handle this safely.



+   (('bcsel', ('feq', '#a', b), c, ('bcsel', ('feq', '#d', b), e, c)), 
('bcsel', ('feq', d, b), e, c)),


     (('bcsel', a, b, b), b),
     (('fcsel', a, b, b), b),
--
2.17.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to