From 0ea763a727d671fa7dab2e37b7592fc045a53396 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 6 Nov 2020 08:49:12 +0100 Subject: [PATCH] aco: add a new Operand flag to indicate that is 16-bit MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit To indicate that the upper 16-bits are always 0 and that optimizing v_mad_u32_u16 to v_mul_u32_u24 is valid. Signed-off-by: Samuel Pitoiset Reviewed-by: Timur Kristóf Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_builder_h.py | 6 ++++++ src/amd/compiler/aco_ir.h | 14 +++++++++++++- src/amd/compiler/aco_print_ir.cpp | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_builder_h.py b/src/amd/compiler/aco_builder_h.py index 426f91c..e2b12fb 100644 --- a/src/amd/compiler/aco_builder_h.py +++ b/src/amd/compiler/aco_builder_h.py @@ -352,6 +352,12 @@ public: } % endfor + + Operand set16bit(Operand op) { + op.set16bit(true); + return op; + } + /* hand-written helpers */ Temp as_uniform(Op op) { diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 39db82c..9ceb24a 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -420,7 +420,7 @@ public: constexpr Operand() : reg_(PhysReg{128}), isTemp_(false), isFixed_(true), isConstant_(false), isKill_(false), isUndef_(true), isFirstKill_(false), constSize(0), - isLateKill_(false) {} + isLateKill_(false), is16bit_(false) {} explicit Operand(Temp r) noexcept { @@ -746,6 +746,17 @@ public: else return other.isTemp() && other.getTemp() == getTemp(); } + + constexpr void set16bit(bool flag) noexcept + { + is16bit_ = flag; + } + + constexpr bool is16bit() const noexcept + { + return is16bit_; + } + private: union { uint32_t i; @@ -763,6 +774,7 @@ private: uint8_t isFirstKill_:1; uint8_t constSize:2; uint8_t isLateKill_:1; + uint8_t is16bit_:1; }; /* can't initialize bit-fields in c++11, so work around using a union */ uint16_t control_ = 0; diff --git a/src/amd/compiler/aco_print_ir.cpp b/src/amd/compiler/aco_print_ir.cpp index 2a90a0a..e679cef 100644 --- a/src/amd/compiler/aco_print_ir.cpp +++ b/src/amd/compiler/aco_print_ir.cpp @@ -168,6 +168,8 @@ static void print_operand(const Operand *operand, FILE *output) } else { if (operand->isLateKill()) fprintf(output, "(latekill)"); + if (operand->is16bit()) + fprintf(output, "(is16bit)"); fprintf(output, "%%%d", operand->tempId()); -- 2.7.4