From e0cefc5a23a62b0bcf77db469adf1d0eb9ff8165 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 6 Mar 2020 16:05:27 -0800 Subject: [PATCH] nir/algebraic: Constant reassociation for bitwise operations too MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Like 5886cd79a0e, but for iand, ior, and ixor. Results on the 308 shaders extracted from the fp64 portion of the OpenGL CTS: Tiger Lake total instructions in shared programs: 903108 -> 902830 (-0.03%) instructions in affected programs: 654910 -> 654632 (-0.04%) helped: 31 HURT: 5 helped stats (abs) min: 2 max: 31 x̄: 9.58 x̃: 7 helped stats (rel) min: 0.01% max: 0.23% x̄: 0.06% x̃: 0.04% HURT stats (abs) min: 1 max: 10 x̄: 3.80 x̃: 3 HURT stats (rel) min: 0.01% max: 0.10% x̄: 0.03% x̃: 0.02% 95% mean confidence interval for instructions value: -10.55 -4.89 95% mean confidence interval for instructions %-change: -0.07% -0.03% Instructions are helped. total cycles in shared programs: 7059681 -> 7058006 (-0.02%) cycles in affected programs: 5081309 -> 5079634 (-0.03%) helped: 33 HURT: 12 helped stats (abs) min: 1 max: 444 x̄: 60.91 x̃: 18 helped stats (rel) min: <.01% max: 2.17% x̄: 0.25% x̃: 0.05% HURT stats (abs) min: 1 max: 288 x̄: 27.92 x̃: 2 HURT stats (rel) min: <.01% max: 1.00% x̄: 0.23% x̃: 0.02% 95% mean confidence interval for cycles value: -68.32 -6.12 95% mean confidence interval for cycles %-change: -0.28% 0.03% Inconclusive result (%-change mean confidence interval includes 0). Ice Lake total instructions in shared programs: 895384 -> 895159 (-0.03%) instructions in affected programs: 658678 -> 658453 (-0.03%) helped: 37 HURT: 0 helped stats (abs) min: 3 max: 16 x̄: 6.08 x̃: 4 helped stats (rel) min: <.01% max: 0.07% x̄: 0.04% x̃: 0.04% 95% mean confidence interval for instructions value: -7.46 -4.70 95% mean confidence interval for instructions %-change: -0.04% -0.03% Instructions are helped. total cycles in shared programs: 7092224 -> 7091195 (-0.01%) cycles in affected programs: 5221666 -> 5220637 (-0.02%) helped: 35 HURT: 11 helped stats (abs) min: 1 max: 247 x̄: 43.46 x̃: 12 helped stats (rel) min: <.01% max: 2.17% x̄: 0.23% x̃: 0.05% HURT stats (abs) min: 2 max: 432 x̄: 44.73 x̃: 5 HURT stats (rel) min: <.01% max: 1.00% x̄: 0.25% x̃: 0.02% 95% mean confidence interval for cycles value: -49.00 4.26 95% mean confidence interval for cycles %-change: -0.27% 0.03% Inconclusive result (value mean confidence interval includes 0). Regular shader-db results: All Haswell+ platforms had similar results. (Tiger Lake shown) total instructions in shared programs: 17611408 -> 17611398 (<.01%) instructions in affected programs: 1648 -> 1638 (-0.61%) helped: 2 HURT: 0 total cycles in shared programs: 338366148 -> 338366124 (<.01%) cycles in affected programs: 124048 -> 124024 (-0.02%) helped: 2 HURT: 0 No changes on any earlier Intel platforms. Reviewed-by: Jason Ekstrand Reviewed-by: Matt Turner Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 3d2f7db5bd2..5cbb9e7c3c2 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -1036,6 +1036,9 @@ optimizations.extend([ (('~fadd', '#a', ('fadd', 'b(is_not_const)', '#c')), ('fadd', ('fadd', a, c), b)), (('~fadd', '#a', ('fneg', ('fadd', 'b(is_not_const)', '#c'))), ('fadd', ('fadd', a, ('fneg', c)), ('fneg', b))), (('iadd', '#a', ('iadd', 'b(is_not_const)', '#c')), ('iadd', ('iadd', a, c), b)), + (('iand', '#a', ('iand', 'b(is_not_const)', '#c')), ('iand', ('iand', a, c), b)), + (('ior', '#a', ('ior', 'b(is_not_const)', '#c')), ('ior', ('ior', a, c), b)), + (('ixor', '#a', ('ixor', 'b(is_not_const)', '#c')), ('ixor', ('ixor', a, c), b)), # Drop mul-div by the same value when there's no wrapping. (('idiv', ('imul(no_signed_wrap)', a, b), b), a), -- 2.30.2