From 4a74c773ff9c3a0427784cb4a166eec5a8fa3b9f Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 20 May 2026 08:55:44 -0400 Subject: [PATCH] jay/liveness: use jay_foreach_preload ..and explain why. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/intel/compiler/jay/jay_liveness.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/intel/compiler/jay/jay_liveness.c b/src/intel/compiler/jay/jay_liveness.c index 831624e6c6a..afd6f1206df 100644 --- a/src/intel/compiler/jay/jay_liveness.c +++ b/src/intel/compiler/jay/jay_liveness.c @@ -154,6 +154,20 @@ jay_calculate_register_demands(jay_function *func) } } + /* Model the implicit demand from preloading inputs. In a function like: + * + * %0 = preload r10 + * %1 = add %0, %0 + * return %1 + * + * ...the "true" register demand is 1, but we need to clamp the demand to 11 + * to make sure r10 actually exists. + */ + jay_foreach_preload(func, I) { + uint32_t max = jay_preload_reg(I) + jay_num_values(I->dst); + max_demand[I->dst.file] = MAX2(max_demand[I->dst.file], max); + } + jay_foreach_block(func, block) { unsigned demands[JAY_NUM_SSA_FILES] = {}; @@ -167,12 +181,6 @@ jay_calculate_register_demands(jay_function *func) } jay_foreach_inst_in_block(block, I) { - /* We must have enough register file space for the register payload */ - if (I->op == JAY_OPCODE_PRELOAD) { - uint32_t max = jay_preload_reg(I) + jay_num_values(I->dst); - max_demand[I->dst.file] = MAX2(max_demand[I->dst.file], max); - } - /* Make destinations live */ jay_foreach_dst(I, d) { demands[d.file] += util_next_power_of_two(jay_num_values(d));