nir/range_analysis: use uint16_t for sparse array elements

ministat (nir_analyze_fp_class):
Difference at 95.0% confidence
    -4484.55 +/- 1288.68
    -0.205419% +/- 0.0589514%
    (Student's t, pooled s = 1521.99)

This should also use less memory.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40346>
This commit is contained in:
Rhys Perry 2026-03-09 09:42:03 +00:00 committed by Marge Bot
parent 5e07201b7c
commit cebf60e059

View file

@ -201,7 +201,7 @@ fp_lookup(void *table, uint32_t key, uint32_t *value)
{
nir_fp_analysis_state *state = table;
if (BITSET_TEST(state->bitset, key)) {
*value = *(uint32_t *)util_sparse_array_get(&state->arr, key);
*value = *(uint16_t *)util_sparse_array_get(&state->arr, key);
return true;
} else {
return false;
@ -214,7 +214,7 @@ fp_insert(void *table, uint32_t key, uint32_t value)
nir_fp_analysis_state *state = table;
BITSET_SET(state->bitset, key);
state->max = MAX2(state->max, (int)key);
*(uint32_t *)util_sparse_array_get(&state->arr, key) = value;
*(uint16_t *)util_sparse_array_get(&state->arr, key) = value;
}
static fp_class_mask
@ -1398,7 +1398,7 @@ nir_create_fp_analysis_state(nir_function_impl *impl)
state.size = BITSET_BYTES(impl->ssa_alloc + impl->ssa_alloc / 4u);
state.max = -1;
state.bitset = calloc(state.size, 1);
util_sparse_array_init(&state.arr, 4, 256);
util_sparse_array_init(&state.arr, 2, 256);
return state;
}