nir/range_analysis: use a dense array
ministat (nir_analyze_fp_class):
Difference at 95.0% confidence
-201983 +/- 1064.87
-9.31575% +/- 0.0468505%
(Student's t, pooled s = 1257.67)
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:
parent
cebf60e059
commit
84eeecf822
2 changed files with 14 additions and 12 deletions
|
|
@ -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 = *(uint16_t *)util_sparse_array_get(&state->arr, key);
|
||||
*value = 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);
|
||||
*(uint16_t *)util_sparse_array_get(&state->arr, key) = value;
|
||||
state->arr[key] = value;
|
||||
}
|
||||
|
||||
static fp_class_mask
|
||||
|
|
@ -1393,22 +1393,25 @@ nir_create_fp_analysis_state(nir_function_impl *impl)
|
|||
{
|
||||
nir_fp_analysis_state state;
|
||||
state.impl = impl;
|
||||
/* Over-allocate the bitset, so that we can keep using the allocated table memory
|
||||
/* Over-allocate, so that we can keep using the allocated table memory
|
||||
* even when new SSA values are added. */
|
||||
state.size = BITSET_BYTES(impl->ssa_alloc + impl->ssa_alloc / 4u);
|
||||
state.size = (impl->ssa_alloc + impl->ssa_alloc / 4u);
|
||||
state.max = -1;
|
||||
state.bitset = calloc(state.size, 1);
|
||||
util_sparse_array_init(&state.arr, 2, 256);
|
||||
state.bitset = calloc(BITSET_BYTES(state.size), 1);
|
||||
state.arr = malloc(state.size * sizeof(uint16_t));
|
||||
return state;
|
||||
}
|
||||
|
||||
void
|
||||
nir_invalidate_fp_analysis_state(nir_fp_analysis_state *state)
|
||||
{
|
||||
if (BITSET_BYTES(state->impl->ssa_alloc) > state->size) {
|
||||
state->size = BITSET_BYTES(state->impl->ssa_alloc + state->impl->ssa_alloc / 4u);
|
||||
if (state->impl->ssa_alloc > state->size) {
|
||||
state->size = state->impl->ssa_alloc + state->impl->ssa_alloc / 4u;
|
||||
|
||||
free(state->arr);
|
||||
free(state->bitset);
|
||||
state->bitset = calloc(state->size, 1);
|
||||
state->arr = malloc(state->size * sizeof(uint16_t));
|
||||
state->bitset = calloc(BITSET_BYTES(state->size), 1);
|
||||
} else if (state->max >= 0) {
|
||||
memset(state->bitset, 0, BITSET_BYTES(state->max + 1));
|
||||
}
|
||||
|
|
@ -1418,7 +1421,7 @@ nir_invalidate_fp_analysis_state(nir_fp_analysis_state *state)
|
|||
void
|
||||
nir_free_fp_analysis_state(nir_fp_analysis_state *state)
|
||||
{
|
||||
util_sparse_array_finish(&state->arr);
|
||||
free(state->arr);
|
||||
free(state->bitset);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#define _NIR_RANGE_ANALYSIS_H_
|
||||
|
||||
#include "util/bitset.h"
|
||||
#include "util/sparse_array.h"
|
||||
#include "util/u_hash_table.h"
|
||||
#include "nir_defines.h"
|
||||
|
||||
|
|
@ -34,7 +33,7 @@ extern "C" {
|
|||
|
||||
typedef struct {
|
||||
nir_function_impl *impl;
|
||||
struct util_sparse_array arr;
|
||||
uint16_t *arr;
|
||||
BITSET_WORD *bitset;
|
||||
uint32_t size;
|
||||
int32_t max;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue