ir3: Propagate coord_offset result from alu src insts

`coord_offset` is called on the source of `alu` instructions and
it returns -1 for failures, this not explicitly checked for and
as a result the fetch can incorrectly be upgraded to a prefetch
when it isn't appropriate to do so.

Signed-off-by: Mark Collins <mark@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19842>
This commit is contained in:
Mark Collins
2022-11-28 08:35:32 +00:00
committed by Marge Bot
parent 83b8687264
commit 5b8917bb91
@@ -48,16 +48,21 @@ coord_offset(nir_ssa_def *ssa)
if (!alu->src[0].src.is_ssa)
return -1;
int base_offset =
coord_offset(alu->src[0].src.ssa) + alu->src[0].swizzle[0];
int base_src_offset = coord_offset(alu->src[0].src.ssa);
if (base_src_offset < 0)
return -1;
int base_offset = base_src_offset + alu->src[0].swizzle[0];
/* NOTE it might be possible to support more than 2D? */
for (int i = 1; i < 2; i++) {
if (!alu->src[i].src.is_ssa)
return -1;
int nth_offset =
coord_offset(alu->src[i].src.ssa) + alu->src[i].swizzle[0];
int nth_src_offset = coord_offset(alu->src[i].src.ssa);
if (nth_src_offset < 0)
return -1;
int nth_offset = nth_src_offset + alu->src[i].swizzle[0];
if (nth_offset != (base_offset + i))
return -1;