mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 02:38:04 +02:00
Merge branch 'nir_lower_bit_size' into 'main'
nir/lower_bit_size: use nir_builder::constant_fold_alu and skip conversion for more opcodes See merge request mesa/mesa!41388
This commit is contained in:
commit
bf07e95578
3 changed files with 19 additions and 6 deletions
|
|
@ -556,9 +556,7 @@ radv_postprocess_nir(const struct radv_compiler_info *compiler_info, const struc
|
|||
if (gfx_level >= GFX8)
|
||||
nir_divergence_analysis(stage->nir);
|
||||
|
||||
if (nir_lower_bit_size(stage->nir, ac_nir_lower_bit_size_callback, &gfx_level)) {
|
||||
NIR_PASS(_, stage->nir, nir_opt_constant_folding);
|
||||
}
|
||||
NIR_PASS(_, stage->nir, nir_lower_bit_size, ac_nir_lower_bit_size_callback, &gfx_level);
|
||||
}
|
||||
if (gfx_level >= GFX9) {
|
||||
bool separate_g16 = gfx_level >= GFX10;
|
||||
|
|
|
|||
|
|
@ -718,6 +718,17 @@ nir_mov_alu(nir_builder *build, nir_alu_src src, unsigned num_components)
|
|||
return src.src.ssa;
|
||||
}
|
||||
|
||||
if (build->constant_fold_alu && nir_src_is_const(src.src)) {
|
||||
nir_const_value dest[NIR_MAX_VEC_COMPONENTS];
|
||||
nir_load_const_instr *load_const = nir_src_as_load_const(src.src);
|
||||
for (unsigned i = 0; i < num_components; i++)
|
||||
dest[i] = load_const->value[src.swizzle[i]];
|
||||
|
||||
return nir_build_imm(build, num_components,
|
||||
nir_src_bit_size(src.src),
|
||||
dest);
|
||||
}
|
||||
|
||||
nir_alu_instr *mov = nir_alu_instr_create(build->shader, nir_op_mov);
|
||||
nir_def_init(&mov->instr, &mov->def, num_components,
|
||||
nir_src_bit_size(src.src));
|
||||
|
|
|
|||
|
|
@ -62,6 +62,9 @@ before_conversion(nir_builder *bld, nir_alu_type type, unsigned bit_size, nir_de
|
|||
case nir_op_ishl:
|
||||
case nir_op_isub:
|
||||
case nir_op_ixor:
|
||||
case nir_op_inot:
|
||||
case nir_op_bcsel:
|
||||
case nir_op_bitfield_select:
|
||||
case nir_op_mov:
|
||||
break;
|
||||
default:
|
||||
|
|
@ -168,9 +171,9 @@ lower_alu_instr(nir_builder *bld, nir_alu_instr *alu, unsigned bit_size)
|
|||
dst_bit_size != bit_size) {
|
||||
nir_alu_type type = nir_op_infos[op].output_type;
|
||||
nir_def *dst = nir_convert_to_bit_size(bld, lowered_dst, type, dst_bit_size);
|
||||
nir_def_rewrite_uses(&alu->def, dst);
|
||||
nir_def_replace(&alu->def, dst);
|
||||
} else {
|
||||
nir_def_rewrite_uses(&alu->def, lowered_dst);
|
||||
nir_def_replace(&alu->def, lowered_dst);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -268,7 +271,7 @@ lower_intrinsic_instr(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
|
||||
res = nir_convert_to_bit_size(b, res, type, old_bit_size);
|
||||
|
||||
nir_def_rewrite_uses(&intrin->def, res);
|
||||
nir_def_replace(&intrin->def, res);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -323,6 +326,7 @@ lower_impl(nir_function_impl *impl,
|
|||
void *callback_data)
|
||||
{
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
b.constant_fold_alu = true;
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_block(block, impl) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue