lima/ppir: fix creation of mov node for non-ssa tex dest
authorErico Nunes <nunes.erico@gmail.com>
Fri, 15 Jan 2021 00:33:16 +0000 (01:33 +0100)
committerMarge Bot <eric+marge@anholt.net>
Sun, 24 Jan 2021 13:35:49 +0000 (13:35 +0000)
In ppir when a texture node has only a single successor, it is used
directly to output the texture lookup value, in order to save the
insertion of a mov.
However, a sequence like this can happen:

  r0 = (float)tex r8 (coord), 0 (texture), 0 (sampler)
  r1 = mov r0.z

In this case, even if the mov is a single successor, the assumption
that only the elements needed by the successor node cannot be made.
The target register can also be read or written elsewhere and so the
simplification cannot be made. Add an exception to cover this case.

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

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

index 2480d79..c16d0f1 100644 (file)
@@ -162,7 +162,7 @@ static bool ppir_lower_texture(ppir_block *block, ppir_node *node)
 {
    ppir_dest *dest = ppir_node_get_dest(node);
 
-   if (ppir_node_has_single_succ(node)) {
+   if (ppir_node_has_single_succ(node) && dest->type == ppir_target_ssa) {
       ppir_node *succ = ppir_node_first_succ(node);
       dest->type = ppir_target_pipeline;
       dest->pipeline = ppir_pipeline_reg_sampler;