From 29f53ee8bbb4b27b13790f92a97b8d0ee7a04329 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 26 Jul 2022 13:22:17 -0400 Subject: [PATCH] pan/bi: Don't write registers in optimizer tests The new SSA-based dead code elimination won't know how to deal with code of that funny form. In actuality it doesn't have to, so we just make sure the optimizer tests produce valid IR so this works as expected. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/ISA.xml | 2 +- src/panfrost/bifrost/test/test-optimizer.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/panfrost/bifrost/ISA.xml b/src/panfrost/bifrost/ISA.xml index fd659e1..e5c600c 100644 --- a/src/panfrost/bifrost/ISA.xml +++ b/src/panfrost/bifrost/ISA.xml @@ -6195,7 +6195,7 @@ - + diff --git a/src/panfrost/bifrost/test/test-optimizer.cpp b/src/panfrost/bifrost/test/test-optimizer.cpp index ccab6cb..73be536 100644 --- a/src/panfrost/bifrost/test/test-optimizer.cpp +++ b/src/panfrost/bifrost/test/test-optimizer.cpp @@ -35,7 +35,14 @@ bi_optimizer(bi_context *ctx) bi_opt_dead_code_eliminate(ctx); } -#define CASE(instr, expected) INSTRUCTION_CASE(instr, expected, bi_optimizer) +/* Define reg first so it has a consistent variable index, and pass it to an + * instruction that cannot be dead code eliminated so the program is nontrivial. + */ +#define CASE(instr, expected) INSTRUCTION_CASE(\ + { UNUSED bi_index reg = bi_temp(b->shader); instr; bi_kaboom(b, reg); }, \ + { UNUSED bi_index reg = bi_temp(b->shader); expected; bi_kaboom(b, reg); }, \ + bi_optimizer); + #define NEGCASE(instr) CASE(instr, instr) class Optimizer : public testing::Test { @@ -43,7 +50,6 @@ protected: Optimizer() { mem_ctx = ralloc_context(NULL); - reg = bi_register(0); x = bi_register(1); y = bi_register(2); negabsx = bi_neg(bi_abs(x)); @@ -55,7 +61,6 @@ protected: void *mem_ctx; - bi_index reg; bi_index x; bi_index y; bi_index negabsx; -- 2.7.4