Mesa (staging/20.0): aco: fix interaction with 3f branch workaround and p_constaddr

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu May 28 18:58:05 UTC 2020


Module: Mesa
Branch: staging/20.0
Commit: e6d75761129b0e9ad2dffd0f67a2b39c9aef7975
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e6d75761129b0e9ad2dffd0f67a2b39c9aef7975

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Fri May 22 15:42:12 2020 +0100

aco: fix interaction with 3f branch workaround and p_constaddr

The offset was incorrect if we inserted a nop before the p_constaddr.

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Fixes: 93c8ebfa ('aco: Initial commit of independent AMD compiler')
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5164>
(cherry picked from commit 8aa98cebc15e6f6f8bcf42162399b5826376b3dc)

---

 .pick_status.json                  | 2 +-
 src/amd/compiler/aco_assembler.cpp | 6 ++----
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 3ac21777d80..d2b16e39f21 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -112,7 +112,7 @@
         "description": "aco: fix interaction with 3f branch workaround and p_constaddr",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "93c8ebfa780ebd1495095e794731881aef29e7d3"
     },
diff --git a/src/amd/compiler/aco_assembler.cpp b/src/amd/compiler/aco_assembler.cpp
index 7683c8f45af..f9dc4bfcf5e 100644
--- a/src/amd/compiler/aco_assembler.cpp
+++ b/src/amd/compiler/aco_assembler.cpp
@@ -30,8 +30,6 @@ struct asm_context {
 
 void emit_instruction(asm_context& ctx, std::vector<uint32_t>& out, Instruction* instr)
 {
-   uint32_t instr_offset = out.size() * 4u;
-
    /* lower remaining pseudo-instructions */
    if (instr->opcode == aco_opcode::p_constaddr) {
       unsigned dest = instr->definitions[0].physReg();
@@ -56,7 +54,7 @@ void emit_instruction(asm_context& ctx, std::vector<uint32_t>& out, Instruction*
       encoding |= 255 << 8;
       out.push_back(encoding);
       ctx.constaddrs.push_back(out.size());
-      out.push_back(-(instr_offset + 4) + offset);
+      out.push_back(offset);
 
       /* s_addc_u32 dest[1], dest[1], 0 */
       encoding = (0b10 << 30);
@@ -695,7 +693,7 @@ void fix_branches(asm_context& ctx, std::vector<uint32_t>& out)
 void fix_constaddrs(asm_context& ctx, std::vector<uint32_t>& out)
 {
    for (unsigned addr : ctx.constaddrs)
-      out[addr] += out.size() * 4u;
+      out[addr] += (out.size() - addr + 1u) * 4u;
 }
 
 unsigned emit_program(Program* program,



More information about the mesa-commit mailing list