agx: Allow uniform sources on phis
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 4 Feb 2023 18:01:38 +0000 (13:01 -0500)
committerMarge Bot <emma+marge@anholt.net>
Sun, 5 Feb 2023 08:53:29 +0000 (08:53 +0000)
The parallel copy lowering has been able to handle uniform sources since 98f0ebf2647 ("agx:
Pass agx_index to agx_copy"), and uniform sources work fine with phis. It's not
super common but there's no need to restrict them. This is a small instruction
count win and will greatly simplify the lowering later in this series.

total instructions in shared programs: 1523806 -> 1523285 (-0.03%)
instructions in affected programs: 17088 -> 16567 (-3.05%)
helped: 38
HURT: 1
helped stats (abs) min: 1.0 max: 44.0 x̄: 13.95 x̃: 7
helped stats (rel) min: 0.42% max: 18.64% x̄: 4.73% x̃: 1.26%
HURT stats (abs)   min: 9.0 max: 9.0 x̄: 9.00 x̃: 9
HURT stats (rel)   min: 8.57% max: 8.57% x̄: 8.57% x̃: 8.57%
95% mean confidence interval for instructions value: -17.95 -8.77
95% mean confidence interval for instructions %-change: -6.35% -2.43%
Instructions are helped.

total bytes in shared programs: 10447658 -> 10444532 (-0.03%)
bytes in affected programs: 118850 -> 115724 (-2.63%)
helped: 38
HURT: 1
helped stats (abs) min: 6.0 max: 264.0 x̄: 83.68 x̃: 45
helped stats (rel) min: 0.36% max: 16.51% x̄: 4.14% x̃: 1.09%
HURT stats (abs)   min: 54.0 max: 54.0 x̄: 54.00 x̃: 54
HURT stats (rel)   min: 7.30% max: 7.30% x̄: 7.30% x̃: 7.30%
95% mean confidence interval for bytes value: -107.68 -52.62
95% mean confidence interval for bytes %-change: -5.55% -2.13%
Bytes are helped.

total halfregs in shared programs: 419446 -> 419444 (<.01%)
halfregs in affected programs: 29 -> 27 (-6.90%)
helped: 1
HURT: 0

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

src/asahi/compiler/agx_liveness.c
src/asahi/compiler/agx_optimizer.c
src/asahi/compiler/agx_register_allocate.c

index 660d379..5154617 100644 (file)
@@ -107,8 +107,8 @@ agx_compute_liveness(agx_context *ctx)
          /* Make live the corresponding source */
          agx_foreach_phi_in_block(blk, phi) {
             agx_index operand = phi->src[agx_predecessor_index(blk, *pred)];
-            assert(operand.type == AGX_INDEX_NORMAL);
-            BITSET_SET(live, operand.value);
+            if (operand.type == AGX_INDEX_NORMAL)
+               BITSET_SET(live, operand.value);
          }
 
          bool progress = false;
index 7e30475..693334b 100644 (file)
@@ -199,8 +199,8 @@ agx_optimizer_copyprop(agx_instr **defs, agx_instr *I)
             (s != 0 || def->src[0].value >= 256)) ||
            (I->op == AGX_OPCODE_DEVICE_STORE &&
             (s != 1 || def->src[0].value >= 256)) ||
-           I->op == AGX_OPCODE_PHI || I->op == AGX_OPCODE_ZS_EMIT ||
-           I->op == AGX_OPCODE_ST_TILE || I->op == AGX_OPCODE_LD_TILE ||
+           I->op == AGX_OPCODE_ZS_EMIT || I->op == AGX_OPCODE_ST_TILE ||
+           I->op == AGX_OPCODE_LD_TILE ||
            I->op == AGX_OPCODE_BLOCK_IMAGE_STORE ||
            I->op == AGX_OPCODE_UNIFORM_STORE || I->op == AGX_OPCODE_ST_VARY))
          continue;
index b4cd2a1..e801de0 100644 (file)
@@ -451,7 +451,6 @@ agx_insert_parallel_copies(agx_context *ctx, agx_block *block)
          agx_index src = phi->src[pred_index];
 
          assert(dest.type == AGX_INDEX_REGISTER);
-         assert(src.type == AGX_INDEX_REGISTER);
          assert(dest.size == src.size);
 
          copies[i++] = (struct agx_copy){