lima/ppir: don't optimize loads with different block successors
authorErico Nunes <nunes.erico@gmail.com>
Sun, 30 Jul 2023 17:12:53 +0000 (19:12 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 1 Aug 2023 18:36:49 +0000 (18:36 +0000)
Even if loads are initially duplicated for each user, with new
optimizations such as folding modifiers, it may happen that loads
end up with only users in different blocks.
Handle that and don't delete or pipeline those nodes.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24246>

src/gallium/drivers/lima/ir/pp/lower.c

index 6170297..ecc19b7 100644 (file)
@@ -98,7 +98,8 @@ static bool ppir_lower_swap_args(ppir_block *block, ppir_node *node)
 static bool ppir_lower_load(ppir_block *block, ppir_node *node)
 {
    ppir_dest *dest = ppir_node_get_dest(node);
-   if (ppir_node_is_root(node) && dest->type == ppir_target_ssa) {
+   if (ppir_node_is_root(node) && !node->succ_different_block &&
+       dest->type == ppir_target_ssa) {
       ppir_node_delete(node);
       return true;
    }
@@ -107,7 +108,8 @@ static bool ppir_lower_load(ppir_block *block, ppir_node *node)
     * that has load node in source
     */
    if ((ppir_node_has_single_src_succ(node) || ppir_node_is_root(node)) &&
-      dest->type != ppir_target_register) {
+       !node->succ_different_block &&
+       dest->type != ppir_target_register) {
       ppir_node *succ = ppir_node_first_succ(node);
       switch (succ->type) {
       case ppir_node_type_alu: