[Mesa-dev] [RFC PATCH 2/2] i965/fs: Allow 2-src math instructions to have immediate src1.

Matt Turner mattst88 at gmail.com
Tue Mar 17 16:23:48 PDT 2015


Without NIR:

total instructions in shared programs: 6190153 -> 6185918 (-0.07%)
instructions in affected programs:     185156 -> 180921 (-2.29%)
helped:                                918

With NIR:

total instructions in shared programs: 6273347 -> 6268409 (-0.08%)
instructions in affected programs:     205735 -> 200797 (-2.40%)
helped:                                1171
GAINED:                                1
---
 src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp | 12 ++++++++----
 src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp  |  6 +++---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp b/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp
index 7ddb253..714d1c2 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_combine_constants.cpp
@@ -62,9 +62,13 @@ could_coissue(const struct brw_context *brw, const fs_inst *inst)
  * Returns true for instructions that don't support immediate sources.
  */
 static bool
-must_promote_imm(const fs_inst *inst)
+must_promote_imm(struct brw_context *brw, const fs_inst *inst)
 {
    switch (inst->opcode) {
+   case SHADER_OPCODE_POW:
+   case SHADER_OPCODE_INT_QUOTIENT:
+   case SHADER_OPCODE_INT_REMAINDER:
+      return brw->gen < 8;
    case BRW_OPCODE_MAD:
    case BRW_OPCODE_LRP:
       return true;
@@ -207,7 +211,7 @@ fs_visitor::opt_combine_constants()
    foreach_block_and_inst(block, fs_inst, inst, cfg) {
       ip++;
 
-      if (!could_coissue(brw, inst) && !must_promote_imm(inst))
+      if (!could_coissue(brw, inst) && !must_promote_imm(brw, inst))
          continue;
 
       for (int i = 0; i < inst->sources; i++) {
@@ -225,7 +229,7 @@ fs_visitor::opt_combine_constants()
             imm->block = intersection;
             imm->uses->push_tail(link(const_ctx, &inst->src[i]));
             imm->uses_by_coissue += could_coissue(brw, inst);
-            imm->must_promote = imm->must_promote || must_promote_imm(inst);
+            imm->must_promote = imm->must_promote || must_promote_imm(brw, inst);
             imm->last_use_ip = ip;
          } else {
             imm = new_imm(&table, const_ctx);
@@ -235,7 +239,7 @@ fs_visitor::opt_combine_constants()
             imm->uses->push_tail(link(const_ctx, &inst->src[i]));
             imm->val = val;
             imm->uses_by_coissue = could_coissue(brw, inst);
-            imm->must_promote = must_promote_imm(inst);
+            imm->must_promote = must_promote_imm(brw, inst);
             imm->first_use_ip = ip;
             imm->last_use_ip = ip;
          }
diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
index 764741d..20b1976 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
@@ -476,9 +476,9 @@ fs_visitor::try_constant_propagate(fs_inst *inst, acp_entry *entry)
       case SHADER_OPCODE_POW:
       case SHADER_OPCODE_INT_QUOTIENT:
       case SHADER_OPCODE_INT_REMAINDER:
-         if (brw->gen < 8)
-            break;
-         /* fallthrough */
+         /* Allow constant propagation into src1 regardless of generation, and
+          * let constant combining promote the constant on Gen < 8.
+          */
       case BRW_OPCODE_BFI1:
       case BRW_OPCODE_ASR:
       case BRW_OPCODE_SHL:
-- 
2.0.5



More information about the mesa-dev mailing list