Mesa (staging/21.2): aco: Unset 16 and 24-bit flags from operands in apply_extract.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 30 16:49:52 UTC 2021


Module: Mesa
Branch: staging/21.2
Commit: 13174690794e52fb47350c83e215467306d4f943
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=13174690794e52fb47350c83e215467306d4f943

Author: Timur Kristóf <timur.kristof at gmail.com>
Date:   Thu Aug 26 10:47:10 2021 +0200

aco: Unset 16 and 24-bit flags from operands in apply_extract.

Consider the following sequence in a shader:
b = p_extract a
c = v_mad_u32_u16 b, X, 0

The optimizer applies extract, resulting in:
c = v_mad_u32_u16 a, X, 0 (correct)

Then it mistakenly turns that into:
c = v_mul_u32_u24 a, X, 0 (incorrect)

In this case, the p_extract is applied to v_mad_u32_u16 by
apply_extract. After this, we can no longer be sure that
the operands are still 16 or 24-bit, so we have to remove
this flag.

No Fossil DB changes.

Fixes: 54292e99c7844500314bfd623469c65adef954c5
Signed-off-by: Timur Kristóf <timur.kristof at gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12558>
(cherry picked from commit 76b9dd6266f4b170e94ee47a6881c3d528c25969)

---

 .pick_status.json                  | 2 +-
 src/amd/compiler/aco_optimizer.cpp | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index 71e5e4e8bfe..bd7584444ab 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -40,7 +40,7 @@
         "description": "aco: Unset 16 and 24-bit flags from operands in apply_extract.",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "54292e99c7844500314bfd623469c65adef954c5"
     },
diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp
index dce88a8b4cf..b26d595bae5 100644
--- a/src/amd/compiler/aco_optimizer.cpp
+++ b/src/amd/compiler/aco_optimizer.cpp
@@ -929,6 +929,9 @@ apply_extract(opt_ctx& ctx, aco_ptr<Instruction>& instr, unsigned idx, ssa_info&
          instr->vop3().opsel |= 1 << idx;
    }
 
+   instr->operands[idx].set16bit(false);
+   instr->operands[idx].set24bit(false);
+
    ctx.info[tmp.id()].label &= ~label_insert;
    /* label_vopc seems to be the only one worth keeping at the moment */
    for (Definition& def : instr->definitions)



More information about the mesa-commit mailing list