r300: Cache the var list in the peephole_mul_omod() loop.
authorEmma Anholt <emma@anholt.net>
Tue, 7 Dec 2021 19:09:06 +0000 (11:09 -0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 8 Dec 2021 02:35:52 +0000 (02:35 +0000)
If we're not making progress (which the function was already giving us!),
then there's no need to recompute the list.  Reduces
pixmark-piano/7.shader_test compile time from 50 seconds to 10.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14117>

src/gallium/drivers/r300/compiler/radeon_optimize.c

index c106d8d..5c825a0 100644 (file)
@@ -881,7 +881,6 @@ static int peephole(struct radeon_compiler * c, struct rc_instruction * inst)
 void rc_optimize(struct radeon_compiler * c, void *user)
 {
        struct rc_instruction * inst = c->Program.Instructions.Next;
-       struct rc_list * var_list;
        while(inst != &c->Program.Instructions) {
                struct rc_instruction * cur = inst;
                inst = inst->Next;
@@ -902,12 +901,15 @@ void rc_optimize(struct radeon_compiler * c, void *user)
        }
 
        inst = c->Program.Instructions.Next;
+       struct rc_list * var_list = NULL;
        while(inst != &c->Program.Instructions) {
                struct rc_instruction * cur = inst;
                inst = inst->Next;
                if (cur->U.I.Opcode == RC_OPCODE_MUL) {
-                       var_list = rc_get_variables(c);
-                       peephole_mul_omod(c, cur, var_list);
+                       if (!var_list)
+                               var_list = rc_get_variables(c);
+                       if (peephole_mul_omod(c, cur, var_list))
+                               var_list = NULL;
                }
        }
 }