aco: fix byte_align_scalar for 3 dword vectors
authorRhys Perry <pendingchaos02@gmail.com>
Mon, 24 Aug 2020 19:00:10 +0000 (20:00 +0100)
committerMarge Bot <eric+marge@anholt.net>
Fri, 4 Sep 2020 13:03:50 +0000 (13:03 +0000)
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Fixes: fe08f0ccf94a7315bded5868b4f6a8bae744de79
   ('aco: add byte_align_scalar() & trim_subdword_vector() helper functions')

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4710>

src/amd/compiler/aco_instruction_selection.cpp

index 9b566442f51537e526bed823a514530aed5f10d7..f7205cd7ef32ebd11cff34ba9403a7e813795ff9 100644 (file)
@@ -447,10 +447,17 @@ void byte_align_scalar(isel_context *ctx, Temp vec, Operand offset, Temp dst)
          emit_split_vector(ctx, dst, 2);
       else
          emit_extract_vector(ctx, tmp, 0, dst);
-   } else if (vec.size() == 4) {
-      Temp lo = bld.tmp(s2), hi = bld.tmp(s2);
-      bld.pseudo(aco_opcode::p_split_vector, Definition(lo), Definition(hi), vec);
-      hi = bld.pseudo(aco_opcode::p_extract_vector, bld.def(s1), hi, Operand(0u));
+   } else if (vec.size() == 3 || vec.size() == 4) {
+      Temp lo = bld.tmp(s2), hi;
+      if (vec.size() == 3) {
+         /* this can happen if we use VMEM for a uniform load */
+         hi = bld.tmp(s1);
+         bld.pseudo(aco_opcode::p_split_vector, Definition(lo), Definition(hi), vec);
+      } else {
+         hi = bld.tmp(s2);
+         bld.pseudo(aco_opcode::p_split_vector, Definition(lo), Definition(hi), vec);
+         hi = bld.pseudo(aco_opcode::p_extract_vector, bld.def(s1), hi, Operand(0u));
+      }
       if (select != Temp())
          hi = bld.sop2(aco_opcode::s_cselect_b32, bld.def(s1), hi, Operand(0u), bld.scc(select));
       lo = bld.sop2(aco_opcode::s_lshr_b64, bld.def(s2), bld.def(s1, scc), lo, shift);