From 2f1bc2bb60638f064ab5537aa14fbdea9dbabdf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Wed, 25 Aug 2021 12:13:39 +0200 Subject: [PATCH] aco: Fix to_uniform_bool_instr when operands are not suitable. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't attempt to transform uniform boolean instructions when their operands are unsuitable. This can happen eg. due to other optimizations that combine SALU instructions which clear out the uniform instruction labels. Cc: mesa-stable Fixes: 8a32f57fff56b3b94f1b5589feba38016f39427c Signed-off-by: Timur Kristóf Reviewed-by: Daniel Schürmann Part-of: (cherry picked from commit abcc83e713467ac5f8f8c52da1d3c8e23b696ee5) --- .pick_status.json | 2 +- src/amd/compiler/aco_optimizer.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 12c248dc4d9..8a89a589836 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1435,7 +1435,7 @@ "description": "aco: Fix to_uniform_bool_instr when operands are not suitable.", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "8a32f57fff56b3b94f1b5589feba38016f39427c" }, diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index 3a09e939b9a..dce88a8b4cf 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -3577,6 +3577,14 @@ combine_instruction(opt_ctx& ctx, aco_ptr& instr) bool to_uniform_bool_instr(opt_ctx& ctx, aco_ptr& instr) { + /* Check every operand to make sure they are suitable. */ + for (Operand& op : instr->operands) { + if (!op.isTemp()) + return false; + if (!ctx.info[op.tempId()].is_uniform_bool() && !ctx.info[op.tempId()].is_uniform_bitwise()) + return false; + } + switch (instr->opcode) { case aco_opcode::s_and_b32: case aco_opcode::s_and_b64: instr->opcode = aco_opcode::s_and_b32; break;