Mesa (master): i965/fs: Add support for constant propagating into sources with modifiers.

Matt Turner mattst88 at kemper.freedesktop.org
Tue Feb 3 20:23:20 UTC 2015


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

Author: Matt Turner <mattst88 at gmail.com>
Date:   Wed Jan 28 18:37:32 2015 -0800

i965/fs: Add support for constant propagating into sources with modifiers.

All but 16 of the programs helped were ARB fp programs.

total instructions in shared programs: 5949286 -> 5945470 (-0.06%)
instructions in affected programs:     275162 -> 271346 (-1.39%)
helped:                                1197
GAINED:                                1

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

---

 .../drivers/dri/i965/brw_fs_copy_propagation.cpp     |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

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 5dd7255..68a266c 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
@@ -448,16 +448,22 @@ fs_visitor::try_constant_propagate(fs_inst *inst, acp_entry *entry)
           (entry->dst.reg_offset + entry->regs_written) * 32)
          continue;
 
-      /* Don't bother with cases that should have been taken care of by the
-       * GLSL compiler's constant folding pass.
-       */
-      if (inst->src[i].negate || inst->src[i].abs)
-         continue;
-
       fs_reg val = entry->src;
       val.effective_width = inst->src[i].effective_width;
       val.type = inst->src[i].type;
 
+      if (inst->src[i].abs) {
+         if (!brw_abs_immediate(val.type, &val.fixed_hw_reg)) {
+            continue;
+         }
+      }
+
+      if (inst->src[i].negate) {
+         if (!brw_negate_immediate(val.type, &val.fixed_hw_reg)) {
+            continue;
+         }
+      }
+
       switch (inst->opcode) {
       case BRW_OPCODE_MOV:
       case SHADER_OPCODE_LOAD_PAYLOAD:




More information about the mesa-commit mailing list