Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/asahi/compiler/agx_validate_ra.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ validate_block(agx_context *ctx, agx_block *block, struct regfile *blocks,
unsigned idx = agx_predecessor_index(block, *pred);
agx_index src = I->src[idx];

assert(ra_class_for_index(src) == cls);
if (!src.has_reg) {
all_same = false;
first = false;
continue;
}
assert(ra_class_for_index(src) == cls);

struct regfile *pred_file = &blocks[(*pred)->index];
struct var_offset var = pred_file->r[cls][src.reg + offs];
Expand Down
34 changes: 34 additions & 0 deletions src/asahi/compiler/test/test-native-form-regressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3425,6 +3425,40 @@ TEST(NativeForms, RegisterValidationTracksPhiCopies)
}
}

TEST(NativeForms, RegisterValidationAllowsNonRegSourceInSpilledPhi)
{
EXPECT_EXIT({
std::signal(SIGABRT, +[](int) { std::_Exit(77); });
void *mem = ralloc_context(NULL);
agx_builder *b = agx_test_builder(mem);
agx_block *entry = agx_start_block(b->shader);
agx_block *left = agx_test_block(b->shader);
agx_block *right = agx_test_block(b->shader);
agx_block *join = agx_test_block(b->shader);
agx_block_add_successor(entry, left);
agx_block_add_successor(entry, right);
agx_block_add_successor(left, join);
agx_block_add_successor(right, join);

b->cursor = agx_after_block(left);
agx_index spilled = validation_span_value(b, true, 80, AGX_SIZE_32, 1);

b->cursor = agx_after_block(join);
agx_index dest = agx_temp(b->shader, AGX_SIZE_32);
dest.memory = true;
dest.has_reg = true;
dest.reg = 80;
agx_instr *phi = agx_phi_to(b, dest, 2);
phi->src[0] = spilled;
phi->src[1] = agx_immediate(0);

agx_unit_test(b, dest);
agx_validate_ra(b->shader);
ralloc_free(mem);
std::_Exit(0);
}, ::testing::ExitedWithCode(0), "");
}

TEST(NativeForms, RegisterValidationRetainsLoopHeaderRules)
{
for (bool invalid_livein : {false, true}) {
Expand Down