pan/mdg: Respect !32-bit sizes in RA
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 7 May 2020 20:10:09 +0000 (16:10 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 21 May 2020 17:49:14 +0000 (17:49 +0000)
So we can take advantage of mediump.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5151>

src/panfrost/midgard/midgard_ra.c

index 729d540af96f9e6339fcb3399ea4b286fe0b9258..f4976560a3566d530f7a6ec945ff9ccee04f6ac1 100644 (file)
@@ -505,17 +505,21 @@ allocate_registers(compiler_context *ctx, bool *spilled)
 
                 if (ins->dest >= SSA_FIXED_MINIMUM) continue;
 
+                unsigned size = nir_alu_type_get_type_size(ins->dest_type);
+
                 /* 0 for x, 1 for xy, 2 for xyz, 3 for xyzw */
-                int class = util_logbase2(ins->mask);
+                int comps1 = util_logbase2(ins->mask);
+
+                int bytes = (comps1 + 1) * (size / 8);
 
                 /* Use the largest class if there's ambiguity, this
                  * handles partial writes */
 
                 int dest = ins->dest;
-                found_class[dest] = MAX2(found_class[dest], class);
+                found_class[dest] = MAX2(found_class[dest], bytes);
 
                 /* XXX: Ensure swizzles align the right way with more LCRA constraints? */
-                if (ins->type == TAG_ALU_4 && ins->alu.reg_mode != midgard_reg_mode_32)
+                if (ins->type == TAG_ALU_4 && size != 32)
                         min_alignment[dest] = 3; /* (1 << 3) = 8 */
 
                 if (ins->type == TAG_LOAD_STORE_4 && ins->load_64)
@@ -532,7 +536,7 @@ allocate_registers(compiler_context *ctx, bool *spilled)
 
         for (unsigned i = 0; i < ctx->temp_count; ++i) {
                 lcra_set_alignment(l, i, min_alignment[i] ? min_alignment[i] : 2);
-                lcra_restrict_range(l, i, (found_class[i] + 1) * 4);
+                lcra_restrict_range(l, i, found_class[i]);
         }
         
         free(found_class);