Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
vkd3d
Manage
Activity
Members
Labels
Plan
Wiki
Bugzilla
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wine
vkd3d
Commits
f5d1b5d2
Commit
f5d1b5d2
authored
1 year ago
by
Giovanni Mascellani
Committed by
Alexandre Julliard
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
vkd3d-shader/ir: Move `break's out of selection constructs when possible.
parent
e29706d3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!764
vkd3d-shader/ir: Remove loops that terminate with a `break'.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libs/vkd3d-shader/ir.c
+68
-0
68 additions, 0 deletions
libs/vkd3d-shader/ir.c
with
68 additions
and
0 deletions
libs/vkd3d-shader/ir.c
+
68
−
0
View file @
f5d1b5d2
...
...
@@ -4115,6 +4115,71 @@ static void vsir_cfg_remove_trailing_continue(struct vsir_cfg_structure_list *li
--
list
->
count
;
}
static
struct
vsir_cfg_structure
*
vsir_cfg_get_trailing_break
(
struct
vsir_cfg_structure_list
*
list
)
{
struct
vsir_cfg_structure
*
structure
;
size_t
count
=
list
->
count
;
if
(
count
==
0
)
return
NULL
;
structure
=
&
list
->
structures
[
count
-
1
];
if
(
structure
->
type
!=
STRUCTURE_TYPE_JUMP
||
structure
->
u
.
jump
.
type
!=
JUMP_BREAK
||
structure
->
u
.
jump
.
condition
)
return
NULL
;
return
structure
;
}
/* When the last instruction in both branches of a selection construct
* is an unconditional break, any of them can be moved after the
* selection construct. If they break the same loop both of them can
* be moved out, otherwise we can choose which one: we choose the one
* that breaks the innermost loop, because we hope to eventually
* remove the loop itself.
*
* In principle a similar movement could be done when the last
* instructions are continue and continue, or continue and break. But
* in practice I don't think those situations can happen given the
* previous passes we do on the program, so we don't care. */
static
enum
vkd3d_result
vsir_cfg_move_breaks_out_of_selections
(
struct
vsir_cfg_structure_list
*
list
)
{
struct
vsir_cfg_structure
*
selection
,
*
if_break
,
*
else_break
,
*
new_break
;
unsigned
int
if_target
,
else_target
,
max_target
;
size_t
pos
=
list
->
count
-
1
;
selection
=
&
list
->
structures
[
pos
];
assert
(
selection
->
type
==
STRUCTURE_TYPE_SELECTION
);
if_break
=
vsir_cfg_get_trailing_break
(
&
selection
->
u
.
selection
.
if_body
);
else_break
=
vsir_cfg_get_trailing_break
(
&
selection
->
u
.
selection
.
else_body
);
if
(
!
if_break
||
!
else_break
)
return
VKD3D_OK
;
if_target
=
if_break
->
u
.
jump
.
target
;
else_target
=
else_break
->
u
.
jump
.
target
;
max_target
=
max
(
if_target
,
else_target
);
if
(
!
(
new_break
=
vsir_cfg_structure_list_append
(
list
,
STRUCTURE_TYPE_JUMP
)))
return
VKD3D_ERROR_OUT_OF_MEMORY
;
new_break
->
u
.
jump
.
type
=
JUMP_BREAK
;
new_break
->
u
.
jump
.
target
=
max_target
;
/* Pointer `selection' could have been invalidated by the append
* operation. */
selection
=
&
list
->
structures
[
pos
];
assert
(
selection
->
type
==
STRUCTURE_TYPE_SELECTION
);
if
(
if_target
==
max_target
)
--
selection
->
u
.
selection
.
if_body
.
count
;
if
(
else_target
==
max_target
)
--
selection
->
u
.
selection
.
else_body
.
count
;
return
VKD3D_OK
;
}
static
enum
vkd3d_result
vsir_cfg_synthesize_selections
(
struct
vsir_cfg_structure_list
*
list
)
{
enum
vkd3d_result
ret
;
...
...
@@ -4155,6 +4220,9 @@ static enum vkd3d_result vsir_cfg_synthesize_selections(struct vsir_cfg_structur
if
((
ret
=
vsir_cfg_synthesize_selections
(
&
structure
->
u
.
selection
.
else_body
))
<
0
)
return
ret
;
if
((
ret
=
vsir_cfg_move_breaks_out_of_selections
(
list
))
<
0
)
return
ret
;
break
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment