summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimur Kristóf <timur.kristof@gmail.com>2021-03-18 10:15:14 +0100
committerMarge Bot <eric+marge@anholt.net>2021-03-18 10:43:41 +0000
commit89c8e22cc65bae26160134145b6c3ef313174713 (patch)
tree0722beda8888f125d9ffab2f538dbe38ab99e714
parent0b090d8e6773678b61e55c2380f7372f62ba1b0a (diff)
aco: Fix constant address offset calculation for ds_read2 instructions.
Cc: mesa-stable Signed-off-by: Timur Kristóf <timur.kristof@gmail.com> Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9678>
-rw-r--r--src/amd/compiler/aco_instruction_selection.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp
index 7b959840d73..feb746aaebb 100644
--- a/src/amd/compiler/aco_instruction_selection.cpp
+++ b/src/amd/compiler/aco_instruction_selection.cpp
@@ -3517,14 +3517,16 @@ Temp lds_load_callback(Builder& bld, const LoadEmitInfo &info,
op = aco_opcode::ds_read_u8;
}
- unsigned max_offset_plus_one = read2 ? 254 * (size / 2u) + 1 : 65536;
- if (const_offset >= max_offset_plus_one) {
- offset = bld.vadd32(bld.def(v1), offset, Operand(const_offset / max_offset_plus_one));
- const_offset %= max_offset_plus_one;
+ unsigned const_offset_unit = read2 ? size / 2u : 1u;
+ unsigned const_offset_range = read2 ? 255 * const_offset_unit : 65536;
+
+ if (const_offset > (const_offset_range - const_offset_unit)) {
+ unsigned excess = const_offset - (const_offset % const_offset_range);
+ offset = bld.vadd32(bld.def(v1), offset, Operand(excess));
+ const_offset -= excess;
}
- if (read2)
- const_offset /= (size / 2u);
+ const_offset /= const_offset_unit;
RegClass rc = RegClass(RegType::vgpr, DIV_ROUND_UP(size, 4));
Temp val = rc == info.dst.regClass() && dst_hint.id() ? dst_hint : bld.tmp(rc);