Mesa (master): aco: create vgpr constant copies using v_bfrev_b32

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Nov 20 20:00:48 UTC 2020


Module: Mesa
Branch: master
Commit: 756bb29391bc368d38472b825510320ddae6042e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=756bb29391bc368d38472b825510320ddae6042e

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Fri Jun  5 19:18:32 2020 +0100

aco: create vgpr constant copies using v_bfrev_b32

Looks like this worked once but broke at some point.

fossil-db (Vega):
Totals from 577 (0.42% of 137413) affected shaders:
CodeSize: 3822052 -> 3818720 (-0.09%)

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5390>

---

 src/amd/compiler/aco_lower_to_hw_instr.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/amd/compiler/aco_lower_to_hw_instr.cpp b/src/amd/compiler/aco_lower_to_hw_instr.cpp
index 1046f7f2f90..df4c0e46259 100644
--- a/src/amd/compiler/aco_lower_to_hw_instr.cpp
+++ b/src/amd/compiler/aco_lower_to_hw_instr.cpp
@@ -984,16 +984,19 @@ void copy_constant(lower_context *ctx, Builder& bld, Definition dst, Operand op)
 {
    assert(op.bytes() == dst.bytes());
 
-   if (dst.regClass() == s1 && op.isLiteral()) {
+   if (dst.bytes() == 4 && op.isLiteral()) {
       uint32_t imm = op.constantValue();
-      if (imm >= 0xffff8000 || imm <= 0x7fff) {
+      if (dst.regClass() == s1 && (imm >= 0xffff8000 || imm <= 0x7fff)) {
          bld.sopk(aco_opcode::s_movk_i32, dst, imm & 0xFFFFu);
          return;
       } else if (util_bitreverse(imm) <= 64 || util_bitreverse(imm) >= 0xFFFFFFF0) {
          uint32_t rev = util_bitreverse(imm);
-         bld.sop1(aco_opcode::s_brev_b32, dst, Operand(rev));
+         if (dst.regClass() == s1)
+            bld.sop1(aco_opcode::s_brev_b32, dst, Operand(rev));
+         else
+            bld.vop1(aco_opcode::v_bfrev_b32, dst, Operand(rev));
          return;
-      } else if (imm != 0) {
+      } else if (dst.regClass() == s1 && imm != 0) {
          unsigned start = (ffs(imm) - 1) & 0x1f;
          unsigned size = util_bitcount(imm) & 0x1f;
          if ((((1u << size) - 1u) << start) == imm) {



More information about the mesa-commit mailing list