Commit 5c2bee59 authored by Kenneth Graunke's avatar Kenneth Graunke Committed by Ian Romanick
Browse files

nir: Let opt_peephole_select allow load_ubo sometimes

In 36f0f031 (circa 2016), Emma Anholt extended nir_opt_peephole_select to
be more aggressive, and allow some simple ALU instructions and not just
moves.  That included nir_intrinsic_load_uniform, since it's common to
read the same uniform in both the if and else case, but process it with
slightly different ALU math.  This improved glmark2 tests by 2x on vc4.

In 2017 a nir_lower_uniforms_to_ubo pass was introduced to optionally
lower uniforms to UBOs.  These days, most drivers use this pass, and
it's called from the common st_glsl_to_nir code.  However, the select
peephole pass is called later, by drivers.  So that means it would not
see load_uniform intrinsics, but rather load_ubo intrinsics.

Effectively, this means that we accidentally disabled the select
peephole for any case which read uniform values on most drivers.

shader-db statistics on Icelake:

   total instructions in shared programs: 19563921 -> 19559786 (-0.02%)
   instructions in affected programs: 246386 -> 242251 (-1.68%)
   helped: 564 / HURT: 0
   helped stats (abs) min: 1 max: 69 x̄: 7.33 x̃: 3
   helped stats (rel) min: 0.10% max: 12.72% x̄: 2.36% x̃: 2.31%
   95% mean confidence interval for instructions value: -8.46 -6.20
   95% mean confidence interval for instructions %-change: -2.52% -2.21%
   Instructions are helped.

   total cycles in shared programs: 849043372 -> 842662124 (-0.75%)
   cycles in affected programs: 64157223 -> 57775975 (-9.95%)
   helped: 841 / HURT: 235
   helped stats (abs) min: 1 max: 166697 x̄: 7606.52 x̃: 32
   helped stats (rel) min: 0.01% max: 63.12% x̄: 3.89% x̃: 1.06%
   HURT stats (abs)   min: 1 max: 790 x̄: 67.39 x̃: 12
   HURT stats (rel)   min: <.01% max: 50.85% x̄: 1.96% x̃: 0.45%
   95% mean confidence interval for cycles value: -7590.95 -4270.11
   95% mean confidence interval for cycles %-change: -3.05% -2.18%
   Cycles are helped.

   One shader dropped a send message.
   SIMD32 churn: +2, -33
parent 81c7b513
Pipeline #745980 waiting for manual action with stages
......@@ -121,6 +121,7 @@ block_check_for_allowed_instrs(nir_block *block, unsigned *count,
}
case nir_intrinsic_load_uniform:
case nir_intrinsic_load_ubo:
case nir_intrinsic_load_helper_invocation:
case nir_intrinsic_is_helper_invocation:
case nir_intrinsic_load_front_face:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment