vkd3d-shader/ir: Move `continue's to the false branch when possible.

This commit is contained in:
Giovanni Mascellani 2024-02-29 16:00:51 +01:00 committed by Alexandre Julliard
parent 4b0a328a2b
commit d8414302e8
Notes: Alexandre Julliard 2024-04-04 22:41:46 +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/722

View File

@ -4115,11 +4115,29 @@ static enum vkd3d_result vsir_cfg_build_structured_program(struct vsir_cfg *cfg)
* next block, in which case we make sure it's the
* false branch. */
if (action_true.jump_type == JUMP_NONE)
{
invert_condition = true;
}
else if (stack_depth >= 2)
{
struct vsir_cfg_structure_list *inner_loop_frame = stack[stack_depth - 2];
struct vsir_cfg_structure *inner_loop = &inner_loop_frame->structures[inner_loop_frame->count - 1];
assert(inner_loop->type == STRUCTURE_TYPE_LOOP);
/* Otherwise, if one of the branches is
* continueing the inner loop we're inside,
* make sure it's the false branch (because it
* will be optimized out later). */
if (action_true.jump_type == JUMP_CONTINUE && action_true.target == inner_loop->u.loop.idx)
invert_condition = true;
}
if (invert_condition)
{
struct vsir_cfg_edge_action tmp = action_true;
action_true = action_false;
action_false = tmp;
invert_condition = true;
}
assert(action_true.jump_type != JUMP_NONE);