Mesa (master): nir/peephole_select: Allow uniform/ input loads and load_const

Jason Ekstrand jekstrand at kemper.freedesktop.org
Wed Mar 18 00:15:21 UTC 2015


Module: Mesa
Branch: master
Commit: 27bf37ba05b69ebf6f373d1637a26b4839265921
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=27bf37ba05b69ebf6f373d1637a26b4839265921

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Mon Mar 16 15:08:04 2015 -0700

nir/peephole_select: Allow uniform/input loads and load_const

Shader-db results on HSW:

total instructions in shared programs: 4174156 -> 4157291 (-0.40%)
instructions in affected programs:     145397 -> 128532 (-11.60%)
helped:                                383
HURT:                                  0
GAINED:                                20
LOST:                                  22

There are two more tests lost than gained.  However, comparing this with
GLSL IR vs. NIR results, the overall delta is reduced from 85/44
gained/lost on current master to 71/32 with this commit.  Therefore, I
think it's probably a boon since we are getting "closer" to where we were
before.

Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>

---

 src/glsl/nir/nir_opt_peephole_select.c |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/glsl/nir/nir_opt_peephole_select.c b/src/glsl/nir/nir_opt_peephole_select.c
index c9512bd..b89451b 100644
--- a/src/glsl/nir/nir_opt_peephole_select.c
+++ b/src/glsl/nir/nir_opt_peephole_select.c
@@ -56,6 +56,31 @@ block_check_for_allowed_instrs(nir_block *block)
 {
    nir_foreach_instr(block, instr) {
       switch (instr->type) {
+      case nir_instr_type_intrinsic: {
+         nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
+
+         switch (intrin->intrinsic) {
+         case nir_intrinsic_load_var:
+            switch (intrin->variables[0]->var->data.mode) {
+            case nir_var_shader_in:
+            case nir_var_uniform:
+               break;
+
+            default:
+               return false;
+            }
+            break;
+
+         default:
+            return false;
+         }
+
+         break;
+      }
+
+      case nir_instr_type_load_const:
+         break;
+
       case nir_instr_type_alu: {
          /* It must be a move operation */
          nir_alu_instr *mov = nir_instr_as_alu(instr);




More information about the mesa-commit mailing list