Module: Mesa Branch: main Commit: 5997cf7587ce56aedac9114c0db9b250f1b54461 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5997cf7587ce56aedac9114c0db9b250f1b54461
Author: Matt Turner <matts...@gmail.com> Date: Tue Jan 9 23:45:27 2024 -0500 nir: Fix cast We were wrongly telling `nir_const_value_as_uint()` that `iter` had `bit_size` bits, but in one case it is explicitly i64. This works on little endian platforms, but caused the nir_loop_unroll_test.fadd{,_rev} tests to fail on big endian platforms. Bug: https://bugs.gentoo.org/921297 Fixes: 268ad47c111 ("nir/loop_analyze: Handle bit sizes correctly in calculate_iterations") Reviewed-by: Rhys Perry <pendingchao...@gmail.com> Reviewed-by: Ian Romanick <ian.d.roman...@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26964> --- src/compiler/nir/nir_loop_analyze.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_loop_analyze.c b/src/compiler/nir/nir_loop_analyze.c index b55da00b962..2b2ebfdd60f 100644 --- a/src/compiler/nir/nir_loop_analyze.c +++ b/src/compiler/nir/nir_loop_analyze.c @@ -827,6 +827,7 @@ get_iteration(nir_op cond_op, nir_const_value initial, nir_const_value step, unsigned execution_mode) { nir_const_value span, iter; + unsigned iter_bit_size = bit_size; switch (invert_comparison_if_needed(cond_op, invert_cond)) { case nir_op_ine: @@ -880,13 +881,14 @@ get_iteration(nir_op cond_op, nir_const_value initial, nir_const_value step, iter = eval_const_binop(nir_op_fdiv, bit_size, span, step, execution_mode); iter = eval_const_unop(nir_op_f2i64, bit_size, iter, execution_mode); + iter_bit_size = 64; break; default: return -1; } - uint64_t iter_u64 = nir_const_value_as_uint(iter, bit_size); + uint64_t iter_u64 = nir_const_value_as_uint(iter, iter_bit_size); return iter_u64 > INT_MAX ? -1 : (int)iter_u64; }