Module: Mesa Branch: staging/23.3 Commit: ebfe425490d0e93c7f735da2db4278842566e16e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ebfe425490d0e93c7f735da2db4278842566e16e
Author: Matt Turner <[email protected]> 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 <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26964> (cherry picked from commit 5997cf7587ce56aedac9114c0db9b250f1b54461) --- .pick_status.json | 2 +- src/compiler/nir/nir_loop_analyze.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 1902091dc6c..4f48cceca2a 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1254,7 +1254,7 @@ "description": "nir: Fix cast", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "268ad47c1115be8a8444d8e0e40af71623f9d281", "notes": null diff --git a/src/compiler/nir/nir_loop_analyze.c b/src/compiler/nir/nir_loop_analyze.c index d9c0492a065..4bb1e0477ca 100644 --- a/src/compiler/nir/nir_loop_analyze.c +++ b/src/compiler/nir/nir_loop_analyze.c @@ -858,6 +858,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: @@ -911,13 +912,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; }
