Mesa (master): vc4: Fix register pressure cost estimates when a src appears twice.

Eric Anholt anholt at kemper.freedesktop.org
Wed Mar 8 21:57:07 UTC 2017


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

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Mar  3 17:03:44 2017 -0800

vc4: Fix register pressure cost estimates when a src appears twice.

This ended up confusing the scheduler for things like fabs (implemented as
fmaxabs x, x) or squaring a number, and it would try to avoid scheduling
them because it appeared more expensive than other instructions.

Fixes failure to register allocate in
dEQP-GLES2.functional.uniform_api.random.3 with almost no shader-db
effects (+.35% max temps)

---

 src/gallium/drivers/vc4/vc4_qir_schedule.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/vc4/vc4_qir_schedule.c b/src/gallium/drivers/vc4/vc4_qir_schedule.c
index 89e6d1d..5118caf 100644
--- a/src/gallium/drivers/vc4/vc4_qir_schedule.c
+++ b/src/gallium/drivers/vc4/vc4_qir_schedule.c
@@ -434,10 +434,20 @@ get_register_pressure_cost(struct schedule_state *state, struct qinst *inst)
                 cost--;
 
         for (int i = 0; i < qir_get_nsrc(inst); i++) {
-                if (inst->src[i].file == QFILE_TEMP &&
-                    !BITSET_TEST(state->temp_live, inst->src[i].index)) {
-                        cost++;
+                if (inst->src[i].file != QFILE_TEMP ||
+                    BITSET_TEST(state->temp_live, inst->src[i].index)) {
+                        continue;
+                }
+
+                bool already_counted = false;
+                for (int j = 0; j < i; j++) {
+                        if (inst->src[i].file == inst->src[j].file &&
+                            inst->src[i].index == inst->src[j].index) {
+                                already_counted = true;
+                        }
                 }
+                if (!already_counted)
+                        cost++;
         }
 
         return cost;




More information about the mesa-commit mailing list