mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-10 16:50:13 +01:00
ac/llvm: don't convert undef to 0 because nir_opt_undef does it now
TOTALS FROM AFFECTED SHADERS (29663/58918) Code Size: 39163724 -> 37842360 (-3.37 %) bytes Max Waves: 394813 -> 396334 (0.39 %) Outputs: 84616 -> 84616 (0.00 %) Patch Outputs: 0 -> 0 (0.00 %) Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24059>
This commit is contained in:
parent
497c40be19
commit
3040aa2e26
3 changed files with 6 additions and 35 deletions
|
|
@ -4129,44 +4129,19 @@ static void phi_post_pass(struct ac_nir_context *ctx)
|
|||
}
|
||||
}
|
||||
|
||||
static bool is_def_used_in_an_export(const nir_def *def)
|
||||
{
|
||||
nir_foreach_use (use_src, def) {
|
||||
if (use_src->parent_instr->type == nir_instr_type_intrinsic) {
|
||||
nir_intrinsic_instr *instr = nir_instr_as_intrinsic(use_src->parent_instr);
|
||||
if (instr->intrinsic == nir_intrinsic_store_deref)
|
||||
return true;
|
||||
} else if (use_src->parent_instr->type == nir_instr_type_alu) {
|
||||
nir_alu_instr *instr = nir_instr_as_alu(use_src->parent_instr);
|
||||
if (instr->op == nir_op_vec4 && is_def_used_in_an_export(&instr->def)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void visit_ssa_undef(struct ac_nir_context *ctx, const nir_undef_instr *instr)
|
||||
{
|
||||
unsigned num_components = instr->def.num_components;
|
||||
LLVMTypeRef type = LLVMIntTypeInContext(ctx->ac.context, instr->def.bit_size);
|
||||
|
||||
if (!ctx->abi->convert_undef_to_zero || is_def_used_in_an_export(&instr->def)) {
|
||||
LLVMValueRef undef;
|
||||
LLVMValueRef undef;
|
||||
|
||||
if (num_components == 1)
|
||||
undef = LLVMGetUndef(type);
|
||||
else {
|
||||
undef = LLVMGetUndef(LLVMVectorType(type, num_components));
|
||||
}
|
||||
ctx->ssa_defs[instr->def.index] = undef;
|
||||
} else {
|
||||
LLVMValueRef zero = LLVMConstInt(type, 0, false);
|
||||
if (num_components > 1) {
|
||||
zero = ac_build_gather_values_extended(&ctx->ac, &zero, num_components, 0, false);
|
||||
}
|
||||
ctx->ssa_defs[instr->def.index] = zero;
|
||||
if (num_components == 1)
|
||||
undef = LLVMGetUndef(type);
|
||||
else {
|
||||
undef = LLVMGetUndef(LLVMVectorType(type, num_components));
|
||||
}
|
||||
ctx->ssa_defs[instr->def.index] = undef;
|
||||
}
|
||||
|
||||
static bool visit_jump(struct ac_llvm_context *ctx, const nir_jump_instr *instr)
|
||||
|
|
|
|||
|
|
@ -79,9 +79,6 @@ struct ac_shader_abi {
|
|||
/* Check for Inf interpolation coeff */
|
||||
bool kill_ps_if_inf_interp;
|
||||
|
||||
/* Whether undef values must be converted to zero */
|
||||
bool convert_undef_to_zero;
|
||||
|
||||
/* Clamp div by 0 (so it won't produce NaN) */
|
||||
bool clamp_div_by_zero;
|
||||
|
||||
|
|
|
|||
|
|
@ -741,7 +741,6 @@ static bool si_llvm_translate_nir(struct si_shader_context *ctx, struct si_shade
|
|||
|
||||
ctx->abi.clamp_shadow_reference = true;
|
||||
ctx->abi.robust_buffer_access = true;
|
||||
ctx->abi.convert_undef_to_zero = true;
|
||||
ctx->abi.load_grid_size_from_user_sgpr = true;
|
||||
ctx->abi.clamp_div_by_zero = ctx->screen->options.clamp_div_by_zero ||
|
||||
info->options & SI_PROFILE_CLAMP_DIV_BY_ZERO;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue