From fd910a096c3ee83303c1f4e6117c4918b5a1a47e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Sun, 18 Sep 2022 18:59:25 +0200 Subject: [PATCH] aco/optimizer_postRA: Don't assume all operand registers were written by same instr. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This assumption is no longer true since the post-RA optimizer can work across blocks. It is now possible that some control flow paths overwrite some but not all registers of an operand. This commit may prevent invalid optimizations and/or assertion failures (on debug builds). Fossil DB stats unaffected on Navi 21. Fixes: 0e4747d3fb7ec15f8c1d6b971b1352249e7d95c6 Signed-off-by: Timur Kristóf Reviewed-by: Daniel Schürmann Part-of: (cherry picked from commit 2eab413cf7964bea3026f43f3c3a12323c281a9c) --- .pick_status.json | 2 +- src/amd/compiler/aco_optimizer_postRA.cpp | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 805a72e3058..7350f387f2c 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2578,7 +2578,7 @@ "description": "aco/optimizer_postRA: Don't assume all operand registers were written by same instr.", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "0e4747d3fb7ec15f8c1d6b971b1352249e7d95c6" }, diff --git a/src/amd/compiler/aco_optimizer_postRA.cpp b/src/amd/compiler/aco_optimizer_postRA.cpp index 0b4a3a71ea7..a7f0c78b367 100644 --- a/src/amd/compiler/aco_optimizer_postRA.cpp +++ b/src/amd/compiler/aco_optimizer_postRA.cpp @@ -127,16 +127,7 @@ last_writer_idx(pr_opt_ctx& ctx, const Operand& op) if (op.isConstant() || op.isUndefined()) return const_or_undef; - assert(op.physReg().reg() < max_reg_cnt); - Idx instr_idx = ctx.instr_idx_by_regs[ctx.current_block->index][op.physReg().reg()]; - -#ifndef NDEBUG - /* Debug mode: */ - instr_idx = last_writer_idx(ctx, op.physReg(), op.regClass()); - assert(instr_idx != written_by_multiple_instrs); -#endif - - return instr_idx; + return last_writer_idx(ctx, op.physReg(), op.regClass()); } bool