mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 15:38:09 +02:00
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: 268ad47c11 ("nir/loop_analyze: Handle bit sizes correctly in calculate_iterations")
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26964>
(cherry picked from commit 5997cf7587)
This commit is contained in:
parent
761ef45a62
commit
ebfe425490
2 changed files with 4 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue