From 24ee0f55f2d99c9c8d611b36016a6f42aa5188cc Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Thu, 3 Dec 2020 11:05:16 +0000 Subject: [PATCH] aco: remove sign-extension in constantValue64() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_ir.h | 10 ++++------ src/amd/compiler/aco_lower_phis.cpp | 12 ++++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 3f72b2e4397..d6e936c6caa 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -642,7 +642,7 @@ public: return isConstant() && constantValue() == cmp; } - constexpr uint64_t constantValue64(bool signext=false) const noexcept + constexpr uint64_t constantValue64() const noexcept { if (constSize == 3) { if (reg_ <= 192) @@ -668,12 +668,10 @@ public: case 247: return 0xC010000000000000; } - } else if (constSize == 1) { - return (signext && (data_.i & 0x8000u) ? 0xffffffffffff0000ull : 0ull) | data_.i; - } else if (constSize == 0) { - return (signext && (data_.i & 0x80u) ? 0xffffffffffffff00ull : 0ull) | data_.i; + unreachable("invalid register for 64-bit constant"); + } else { + return data_.i; } - return (signext && (data_.i & 0x80000000u) ? 0xffffffff00000000ull : 0ull) | data_.i; } constexpr bool isOfType(RegType type) const noexcept diff --git a/src/amd/compiler/aco_lower_phis.cpp b/src/amd/compiler/aco_lower_phis.cpp index e3047d6a5b1..da703e01bd6 100644 --- a/src/amd/compiler/aco_lower_phis.cpp +++ b/src/amd/compiler/aco_lower_phis.cpp @@ -132,8 +132,8 @@ void build_merge_code(Program *program, Block *block, Definition dst, Operand pr return; } - bool prev_is_constant = prev.isConstant() && prev.constantValue64(true) + 1u < 2u; - bool cur_is_constant = cur.isConstant() && cur.constantValue64(true) + 1u < 2u; + bool prev_is_constant = prev.isConstant() && prev.constantValue() + 1u < 2u; + bool cur_is_constant = cur.isConstant() && cur.constantValue() + 1u < 2u; if (!prev_is_constant) { if (!cur_is_constant) { @@ -141,22 +141,22 @@ void build_merge_code(Program *program, Block *block, Definition dst, Operand pr bld.sop2(Builder::s_andn2, Definition(tmp1), bld.def(s1, scc), prev, Operand(exec, bld.lm)); bld.sop2(Builder::s_and, Definition(tmp2), bld.def(s1, scc), cur, Operand(exec, bld.lm)); bld.sop2(Builder::s_or, dst, bld.def(s1, scc), tmp1, tmp2); - } else if (cur.constantValue64(true)) { + } else if (cur.constantValue()) { bld.sop2(Builder::s_or, dst, bld.def(s1, scc), prev, Operand(exec, bld.lm)); } else { bld.sop2(Builder::s_andn2, dst, bld.def(s1, scc), prev, Operand(exec, bld.lm)); } - } else if (prev.constantValue64(true)) { + } else if (prev.constantValue()) { if (!cur_is_constant) bld.sop2(Builder::s_orn2, dst, bld.def(s1, scc), cur, Operand(exec, bld.lm)); - else if (cur.constantValue64(true)) + else if (cur.constantValue()) bld.copy(dst, Operand(UINT32_MAX, bld.lm == s2)); else bld.sop1(Builder::s_not, dst, bld.def(s1, scc), Operand(exec, bld.lm)); } else { if (!cur_is_constant) bld.sop2(Builder::s_and, dst, bld.def(s1, scc), cur, Operand(exec, bld.lm)); - else if (cur.constantValue64(true)) + else if (cur.constantValue()) bld.copy(dst, Operand(exec, bld.lm)); else bld.copy(dst, Operand(0u, bld.lm == s2));