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

Author: Eric Anholt <[email protected]>
Date:   Mon Jul 16 13:27:13 2018 -0700

v3d: Emit the lowered uniform just before its first use in a block.

total instructions in shared programs: 98578 -> 98119 (-0.47%)
instructions in affected programs:     27571 -> 27112 (-1.66%)

and it also eliminates most spills/fills on the CTS's randomized uniform
usage testcases.

---

 src/broadcom/compiler/vir_lower_uniforms.c | 38 ++++++++++++++----------------
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/src/broadcom/compiler/vir_lower_uniforms.c 
b/src/broadcom/compiler/vir_lower_uniforms.c
index 7f3bb8460e..97375b483b 100644
--- a/src/broadcom/compiler/vir_lower_uniforms.c
+++ b/src/broadcom/compiler/vir_lower_uniforms.c
@@ -152,7 +152,7 @@ vir_lower_uniforms(struct v3d_compile *c)
                  * reference a temp instead.
                  */
                 vir_for_each_block(block, c) {
-                        struct qinst *mov = NULL;
+                        struct qreg temp = c->undef;
 
                         vir_for_each_inst(inst, block) {
                                 uint32_t nsrc = vir_get_nsrc(inst);
@@ -162,29 +162,27 @@ vir_lower_uniforms(struct v3d_compile *c)
                                 if (count <= 1)
                                         continue;
 
-                                /* If the block doesn't have a load of the
-                                 * uniform yet, add it.  We could potentially
-                                 * do better and CSE MOVs from multiple blocks
-                                 * into dominating blocks, except that may
-                                 * cause troubles for register allocation.
-                                 */
-                                if (!mov) {
-                                        mov = vir_mul_inst(V3D_QPU_M_MOV,
-                                                           vir_get_temp(c),
-                                                           unif, c->undef);
-                                        list_add(&mov->link,
-                                                 &block->instructions);
-                                        c->defs[mov->dst.index] = mov;
-                                }
-
                                 bool removed = false;
                                 for (int i = 0; i < nsrc; i++) {
                                         if (is_lowerable_uniform(inst, i) &&
                                             inst->src[i].index == max_index) {
-                                                inst->src[i].file =
-                                                        mov->dst.file;
-                                                inst->src[i].index =
-                                                        mov->dst.index;
+                                                /* If the block doesn't have a
+                                                 * load of the uniform yet,
+                                                 * add it now.  We could
+                                                 * potentially do better and
+                                                 * CSE MOVs from multiple
+                                                 * blocks into dominating
+                                                 * blocks, except that may
+                                                 * cause troubles for register
+                                                 * allocation.
+                                                 */
+                                                if (temp.file == QFILE_NULL) {
+                                                        c->cursor =
+                                                                
vir_before_inst(inst);
+                                                        temp = vir_MOV(c, 
unif);
+                                                }
+
+                                                inst->src[i] = temp;
                                                 remove_uniform(ht, unif);
                                                 removed = true;
                                         }

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to