diff options
author | Kenneth Graunke <[email protected]> | 2019-01-31 22:02:55 -0800 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2019-02-05 13:51:50 -0800 |
commit | fa38ca25f6ab5ce55450442d01791dd68f0a90f4 (patch) | |
tree | 1e7d7aae3511648afebaa1f0d61f18511e11e3d6 | |
parent | a01ad3110a92e88f815242b59ad1da6d2623decc (diff) |
program: Use u_bit_scan64 in prog_to_nir.
We can simply iterate the bits rather than using util_last_bit and
checking each one up until that point.
Reviewed-by: Eric Anholt <[email protected]>
-rw-r--r-- | src/mesa/program/prog_to_nir.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c index 10ba037d428..0f7601a6868 100644 --- a/src/mesa/program/prog_to_nir.c +++ b/src/mesa/program/prog_to_nir.c @@ -858,10 +858,9 @@ setup_registers_and_variables(struct ptn_compile *c) struct nir_shader *shader = b->shader; /* Create input variables. */ - const int num_inputs = util_last_bit64(c->prog->info.inputs_read); - for (int i = 0; i < num_inputs; i++) { - if (!(c->prog->info.inputs_read & BITFIELD64_BIT(i))) - continue; + uint64_t inputs_read = c->prog->info.inputs_read; + while (inputs_read) { + const int i = u_bit_scan64(&inputs_read); nir_variable *var = nir_variable_create(shader, nir_var_shader_in, glsl_vec4_type(), @@ -907,9 +906,9 @@ setup_registers_and_variables(struct ptn_compile *c) int max_outputs = util_last_bit(c->prog->info.outputs_written); c->output_regs = rzalloc_array(c, nir_register *, max_outputs); - for (int i = 0; i < max_outputs; i++) { - if (!(c->prog->info.outputs_written & BITFIELD64_BIT(i))) - continue; + uint64_t outputs_written = c->prog->info.outputs_written; + while (outputs_written) { + const int i = u_bit_scan64(&outputs_written); /* Since we can't load from outputs in the IR, we make temporaries * for the outputs and emit stores to the real outputs at the end of |