bool nir_lower_indirect_var_derefs(nir_shader *shader,
const struct set *vars);
-bool nir_lower_locals_to_regs(nir_shader *shader);
+bool nir_lower_locals_to_regs(nir_shader *shader, uint8_t bool_bitsize);
void nir_lower_io_to_temporaries(nir_shader *shader,
nir_function_impl *entrypoint,
/* A hash table mapping derefs to registers */
struct hash_table *regs_table;
+ /* Bit size to use for boolean registers */
+ uint8_t bool_bitsize;
+
bool progress;
};
reg->num_array_elems = array_size > 1 ? array_size : 0;
reg->bit_size = glsl_get_bit_size(deref->type);
+ if (reg->bit_size == 1)
+ reg->bit_size = state->bool_bitsize;
+
_mesa_hash_table_insert_pre_hashed(state->regs_table, hash, deref, reg);
return reg;
}
static bool
-nir_lower_locals_to_regs_impl(nir_function_impl *impl)
+nir_lower_locals_to_regs_impl(nir_function_impl *impl, uint8_t bool_bitsize)
{
struct locals_to_regs_state state;
nir_builder_init(&state.builder, impl);
state.progress = false;
state.regs_table = _mesa_hash_table_create(NULL, hash_deref, derefs_equal);
+ state.bool_bitsize = bool_bitsize;
nir_metadata_require(impl, nir_metadata_dominance);
}
bool
-nir_lower_locals_to_regs(nir_shader *shader)
+nir_lower_locals_to_regs(nir_shader *shader, uint8_t bool_bitsize)
{
bool progress = false;
nir_foreach_function(function, shader) {
- if (function->impl)
- progress = nir_lower_locals_to_regs_impl(function->impl) || progress;
+ if (function->impl) {
+ progress =
+ nir_lower_locals_to_regs_impl(function->impl, bool_bitsize) ||
+ progress;
+ }
}
return progress;
*/
bool progress = false;
bool needs_late_alg = false;
- NIR_PASS(progress, ctx->s, nir_lower_locals_to_regs);
+ NIR_PASS(progress, ctx->s, nir_lower_locals_to_regs, 1);
/* we could need cleanup after lower_locals_to_regs */
while (progress) {
struct nir_function *func;
nir_convert_from_ssa(nir, true);
- nir_lower_locals_to_regs(nir);
+ nir_lower_locals_to_regs(nir, 32);
nir_remove_dead_derefs(nir);
nir_remove_dead_variables(nir, nir_var_function_temp, NULL);
NIR_PASS_V(s, nir_lower_vec_to_movs, ntt_vec_to_mov_writemask_cb, NULL);
/* locals_to_regs will leave dead derefs that are good to clean up. */
- NIR_PASS_V(s, nir_lower_locals_to_regs);
+ NIR_PASS_V(s, nir_lower_locals_to_regs, 32);
NIR_PASS_V(s, nir_opt_dce);
if (NIR_DEBUG(TGSI)) {
NIR_PASS_V(sh, nir_lower_bool_to_int32);
- NIR_PASS_V(sh, nir_lower_locals_to_regs);
+ NIR_PASS_V(sh, nir_lower_locals_to_regs, 32);
NIR_PASS_V(sh, nir_convert_from_ssa, true);
NIR_PASS_V(sh, nir_opt_dce);
OPT(nir_copy_prop);
OPT(nir_opt_dce);
- OPT(nir_lower_locals_to_regs);
+ OPT(nir_lower_locals_to_regs, 32);
if (unlikely(debug_enabled)) {
/* Re-index SSA defs so we print more sensible numbers. */