vkd3d-shader/ir: Swap selection branches if the if branch is empty.

This commit is contained in:
Giovanni Mascellani 2024-03-15 13:06:27 +01:00 committed by Alexandre Julliard
parent 0515482e82
commit d6ba8b88fa
Notes: Alexandre Julliard 2024-04-16 23:25:43 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Conor McCarthy (@cmccarthy)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/785

View File

@ -4268,6 +4268,17 @@ static enum vkd3d_result vsir_cfg_move_breaks_out_of_selections(struct vsir_cfg
--cfg->loop_intervals[else_target].target_count;
}
/* If a branch becomes empty, make it the else branch, so we save a block. */
if (selection->u.selection.if_body.count == 0)
{
struct vsir_cfg_structure_list tmp;
selection->u.selection.invert_condition = !selection->u.selection.invert_condition;
tmp = selection->u.selection.if_body;
selection->u.selection.if_body = selection->u.selection.else_body;
selection->u.selection.else_body = tmp;
}
return VKD3D_OK;
}