pan/mdg: Constant fold after algebraic_late

Late algebraic lowering turns fsub(x, #y) into fadd(x, fneg(#y)), we should
constant fold that into fadd(x, #-y).

   total instructions in shared programs: 1518414 -> 1518138 (-0.02%)
   instructions in affected programs: 18363 -> 18087 (-1.50%)
   helped: 68
   HURT: 0
   Instructions are helped.

   total bundles in shared programs: 646938 -> 646877 (<.01%)
   bundles in affected programs: 8299 -> 8238 (-0.74%)
   helped: 56
   HURT: 17
   Bundles are helped.

   total quadwords in shared programs: 1134323 -> 1133694 (-0.06%)
   quadwords in affected programs: 77445 -> 76816 (-0.81%)
   helped: 450
   HURT: 8
   Quadwords are helped.

   total registers in shared programs: 90618 -> 90624 (<.01%)
   registers in affected programs: 129 -> 135 (4.65%)
   helped: 5
   HURT: 11
   Inconclusive result (value mean confidence interval includes 0).

   total threads in shared programs: 55563 -> 55561 (<.01%)
   threads in affected programs: 4 -> 2 (-50.00%)
   helped: 0
   HURT: 2

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Italo Nicola <italonicola@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23769>
This commit is contained in:
Alyssa Rosenzweig 2023-06-20 18:03:32 -04:00
parent e8ffbc77b5
commit 50449167d5

View file

@ -461,8 +461,14 @@ optimise_nir(nir_shader *nir, unsigned quirks, bool is_blend)
NIR_PASS(progress, nir, midgard_nir_cancel_inot);
NIR_PASS_V(nir, midgard_nir_type_csel);
NIR_PASS(progress, nir, nir_copy_prop);
NIR_PASS(progress, nir, nir_opt_dce);
/* Clean up after late opts */
do {
progress = false;
NIR_PASS(progress, nir, nir_opt_dce);
NIR_PASS(progress, nir, nir_opt_constant_folding);
NIR_PASS(progress, nir, nir_copy_prop);
} while (progress);
/* Backend scheduler is purely local, so do some global optimizations
* to reduce register pressure. */