[Mesa-dev] [PATCH 8/8] intel/compiler: Use partial redundancy elimination for compares

Ian Romanick idr at freedesktop.org
Wed Jun 6 21:33:23 UTC 2018


From: Ian Romanick <ian.d.romanick at intel.com>

Almost all of the hurt shaders are repeated instances of the same shader
in synmark's compilation speed tests.

shader-db results:

All Gen7+ platforms had similar results. (Haswell shown)
total instructions in shared programs: 12944679 -> 12943956 (<.01%)
instructions in affected programs: 59749 -> 59026 (-1.21%)
helped: 329
HURT: 0
helped stats (abs) min: 1 max: 9 x̄: 2.20 x̃: 1
helped stats (rel) min: 0.11% max: 23.53% x̄: 1.85% x̃: 1.27%
95% mean confidence interval for instructions value: -2.37 -2.03
95% mean confidence interval for instructions %-change: -2.15% -1.56%
Instructions are helped.

total cycles in shared programs: 410012259 -> 409991735 (<.01%)
cycles in affected programs: 786938 -> 766414 (-2.61%)
helped: 243
HURT: 50
helped stats (abs) min: 1 max: 417 x̄: 86.98 x̃: 18
helped stats (rel) min: <.01% max: 29.16% x̄: 5.69% x̃: 1.04%
HURT stats (abs)   min: 2 max: 130 x̄: 12.22 x̃: 5
HURT stats (rel)   min: <.01% max: 14.67% x̄: 0.83% x̃: 0.09%
95% mean confidence interval for cycles value: -85.80 -54.30
95% mean confidence interval for cycles %-change: -5.62% -3.54%
Cycles are helped.

Sandy Bridge
total instructions in shared programs: 10421031 -> 10420472 (<.01%)
instructions in affected programs: 59999 -> 59440 (-0.93%)
helped: 297
HURT: 0
helped stats (abs) min: 1 max: 9 x̄: 1.88 x̃: 1
helped stats (rel) min: 0.11% max: 22.22% x̄: 1.59% x̃: 0.88%
95% mean confidence interval for instructions value: -2.04 -1.72
95% mean confidence interval for instructions %-change: -1.88% -1.30%
Instructions are helped.

total cycles in shared programs: 146060196 -> 146054402 (<.01%)
cycles in affected programs: 1009543 -> 1003749 (-0.57%)
helped: 281
HURT: 9
helped stats (abs) min: 1 max: 76 x̄: 21.88 x̃: 12
helped stats (rel) min: 0.04% max: 6.43% x̄: 0.85% x̃: 0.66%
HURT stats (abs)   min: 1 max: 161 x̄: 39.22 x̃: 6
HURT stats (rel)   min: 0.04% max: 14.64% x̄: 3.91% x̃: 0.69%
95% mean confidence interval for cycles value: -23.15 -16.81
95% mean confidence interval for cycles %-change: -0.88% -0.52%
Cycles are helped.

Iron Lake
total instructions in shared programs: 7780915 -> 7780598 (<.01%)
instructions in affected programs: 36518 -> 36201 (-0.87%)
helped: 116
HURT: 0
helped stats (abs) min: 1 max: 9 x̄: 2.73 x̃: 2
helped stats (rel) min: 0.27% max: 14.29% x̄: 1.97% x̃: 0.75%
95% mean confidence interval for instructions value: -3.01 -2.45
95% mean confidence interval for instructions %-change: -2.55% -1.39%
Instructions are helped.

total cycles in shared programs: 177876108 -> 177874792 (<.01%)
cycles in affected programs: 636218 -> 634902 (-0.21%)
helped: 113
HURT: 2
helped stats (abs) min: 2 max: 36 x̄: 11.68 x̃: 12
helped stats (rel) min: 0.04% max: 3.19% x̄: 0.47% x̃: 0.23%
HURT stats (abs)   min: 2 max: 2 x̄: 2.00 x̃: 2
HURT stats (rel)   min: 0.04% max: 0.09% x̄: 0.06% x̃: 0.06%
95% mean confidence interval for cycles value: -12.51 -10.38
95% mean confidence interval for cycles %-change: -0.57% -0.36%
Cycles are helped.

GM45
total instructions in shared programs: 4799152 -> 4798939 (<.01%)
instructions in affected programs: 22520 -> 22307 (-0.95%)
helped: 71
HURT: 0
helped stats (abs) min: 1 max: 9 x̄: 3.00 x̃: 2
helped stats (rel) min: 0.27% max: 13.73% x̄: 2.01% x̃: 1.09%
95% mean confidence interval for instructions value: -3.37 -2.63
95% mean confidence interval for instructions %-change: -2.76% -1.26%
Instructions are helped.

total cycles in shared programs: 122052654 -> 122051658 (<.01%)
cycles in affected programs: 387236 -> 386240 (-0.26%)
helped: 70
HURT: 1
helped stats (abs) min: 4 max: 36 x̄: 14.26 x̃: 12
helped stats (rel) min: 0.06% max: 3.19% x̄: 0.58% x̃: 0.52%
HURT stats (abs)   min: 2 max: 2 x̄: 2.00 x̃: 2
HURT stats (rel)   min: 0.09% max: 0.09% x̄: 0.09% x̃: 0.09%
95% mean confidence interval for cycles value: -15.36 -12.69
95% mean confidence interval for cycles %-change: -0.72% -0.42%
Cycles are helped.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/intel/compiler/brw_nir.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c
index ca9b021767f..22b24f36d0e 100644
--- a/src/intel/compiler/brw_nir.c
+++ b/src/intel/compiler/brw_nir.c
@@ -772,6 +772,21 @@ brw_postprocess_nir(nir_shader *nir, const struct brw_compiler *compiler,
       OPT(brw_nir_opt_peephole_ffma);
    }
 
+   if (OPT(nir_opt_comparison_pre)) {
+      OPT(nir_copy_prop);
+      OPT(nir_opt_dce);
+      OPT(nir_opt_cse);
+
+      /* Do the select peepehole again.  nir_opt_comparison_pre (combined with
+       * the other optimization passes) will have removed at least one
+       * instruction from one of the branches of the if-statement, so now it
+       * might be under the threshold of conversion to bcsel.
+       */
+      OPT(nir_opt_peephole_select, 0);
+      if (devinfo->gen >= 6)
+         OPT(nir_opt_peephole_select, 1);
+   }
+
    OPT(nir_opt_algebraic_late);
 
    OPT(nir_lower_to_source_mods);
-- 
2.14.4



More information about the mesa-dev mailing list