shader-db results based on my scalarizing patches: total instructions in shared programs: 6077319 -> 6076895 (-0.01%) instructions in affected programs: 63509 -> 63085 (-0.67%) helped: 306 HURT: 0 GAINED: 0 LOST: 0 --- src/glsl/nir/nir_opt_algebraic.py | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py index 169bb41..5e40ef5 100644 --- a/src/glsl/nir/nir_opt_algebraic.py +++ b/src/glsl/nir/nir_opt_algebraic.py @@ -72,4 +72,17 @@ optimizations = [ (('feq', ('fadd', a, b), 0.0), ('feq', a, ('fneg', b))), ] +# Add optimizations to handle the case where the result of a ternary is +# compared to a constant. This way we can take things like +for op in ['flt', 'fge', 'feq', 'fne', + 'ilt', 'ige', 'ieq', 'ine', 'ult', 'uge']: + optimizations += [ + ((op, ('bcsel', 'a', '#b', '#c'), '#d'), + ('bcsel', 'a', (op, 'b', 'd'), (op, 'c', 'd'))), + ((op, '#d', ('bcsel', a, '#b', '#c')), + ('bcsel', 'a', (op, 'd', 'b'), (op, 'd', 'c'))), + (('bcsel', (op, 'a', 'b'), True, False), (op, 'a', 'b')), + (('bcsel', (op, 'a', 'b'), False, True), ('inot', (op, 'a', 'b'))), + ] + print nir_algebraic.AlgebraicPass("nir_opt_algebraic", optimizations).render() -- 2.2.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev