From 66616f08620ff025859f6c3802c2c464eb1d2489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 25 Mar 2024 18:08:29 +0100 Subject: [PATCH] aco/spill: Fix assertion for nested loops Fixes: 898fd9227a7e4d5bf2a6ff5c3cce17dc7d0fc964 ('aco/spill: keep loop variables spilled during nested loops') Part-of: --- src/amd/compiler/aco_spill.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp index c9e6cb62106..6e79a476325 100644 --- a/src/amd/compiler/aco_spill.cpp +++ b/src/amd/compiler/aco_spill.cpp @@ -535,9 +535,11 @@ init_live_in_vars(spill_ctx& ctx, Block* block, unsigned block_idx) if (!ctx.loop.empty()) { /* If this is a nested loop, keep variables from the outer loop spilled. */ for (auto spilled : ctx.loop.back().spills) { - assert(next_use_distances.count(spilled.first)); - - if (ctx.spills_entry[block_idx].insert(spilled).second) { + /* If the inner loop comes after the last continue statement of the outer loop, + * the loop-carried variables might not be live-in for the inner loop. + */ + if (next_use_distances.count(spilled.first) && + ctx.spills_entry[block_idx].insert(spilled).second) { spilled_registers += spilled.first; loop_demand -= spilled.first; }