From e419eefd3483e98580481d98b2176484c423b64a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 26 Jul 2022 08:55:45 -0700 Subject: [PATCH] intel/fs: Use nir_opt_reassociate_bfi All Skylake and newer Intel platforms had similar results. (Ice Lake shown) total instructions in shared programs: 19907072 -> 19907054 (<.01%) instructions in affected programs: 8859 -> 8841 (-0.20%) helped: 9 / HURT: 0 total cycles in shared programs: 855791238 -> 855779334 (<.01%) cycles in affected programs: 3308294 -> 3296390 (-0.36%) helped: 12 / HURT: 13 Broadwell total instructions in shared programs: 17818231 -> 17817440 (<.01%) instructions in affected programs: 9887 -> 9096 (-8.00%) helped: 9 / HURT: 0 total cycles in shared programs: 902970035 -> 902941221 (<.01%) cycles in affected programs: 2767243 -> 2738429 (-1.04%) helped: 14 / HURT: 5 total spills in shared programs: 17784 -> 17718 (-0.37%) spills in affected programs: 318 -> 252 (-20.75%) helped: 1 / HURT: 0 total fills in shared programs: 25458 -> 24949 (-2.00%) fills in affected programs: 1346 -> 837 (-37.82%) helped: 1 / HURT: 0 Haswell total instructions in shared programs: 16707799 -> 16707586 (<.01%) instructions in affected programs: 24049 -> 23836 (-0.89%) helped: 41 / HURT: 0 total cycles in shared programs: 882730648 -> 882723174 (<.01%) cycles in affected programs: 5096737 -> 5089263 (-0.15%) helped: 25 / HURT: 12 total spills in shared programs: 14937 -> 14909 (-0.19%) spills in affected programs: 436 -> 408 (-6.42%) helped: 4 / HURT: 0 total fills in shared programs: 17569 -> 17529 (-0.23%) fills in affected programs: 444 -> 404 (-9.01%) helped: 4 / HURT: 0 No shader-db changes on any older Intel platforms. All Intel platforms had similar results. (Ice Lake shown) Totals: Instrs: 153118594 -> 153117340 (-0.00%); split: -0.00%, +0.00% Cycles: 15011967556 -> 15011904351 (-0.00%); split: -0.00%, +0.00% Fill count: 203692 -> 203684 (-0.00%) Totals from 703 (0.11% of 662496) affected shaders: Instrs: 192826 -> 191572 (-0.65%); split: -0.65%, +0.00% Cycles: 29937640 -> 29874435 (-0.21%); split: -0.25%, +0.04% Fill count: 4146 -> 4138 (-0.19%) Reviewed-by: Matt Turner Part-of: --- src/intel/compiler/brw_nir.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index eea8c374fd2..2960eb7ef1e 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -710,6 +710,13 @@ brw_nir_optimize(nir_shader *nir, const struct brw_compiler *compiler) OPT(nir_opt_intrinsics); OPT(nir_opt_idiv_const, 32); OPT(nir_opt_algebraic); + + /* BFI2 did not exist until Gfx7, so there's no point in trying to + * optimize an instruction that should not get generated. + */ + if (compiler->devinfo->ver >= 7) + OPT(nir_opt_reassociate_bfi); + OPT(nir_lower_constant_convert_alu_types); OPT(nir_opt_constant_folding);