pan/bi: Don't write registers in optimizer tests
authorAlyssa Rosenzweig <alyssa@collabora.com>
Tue, 26 Jul 2022 17:22:17 +0000 (13:22 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 2 Sep 2022 16:03:23 +0000 (16:03 +0000)
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 <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17794>

src/panfrost/bifrost/ISA.xml
src/panfrost/bifrost/test/test-optimizer.cpp

index fd659e1..e5c600c 100644 (file)
     <src start="6" mask="0xf7"/>
   </ins>
 
-  <ins name="+KABOOM" mask="0xffff8" exact="0xd7858" unused="true" message="job_management">
+  <ins name="+KABOOM" mask="0xffff8" exact="0xd7858" message="job" dests="0">
     <src start="0"/>
   </ins>
 
index ccab6cb..73be536 100644 (file)
@@ -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;