mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
nir/opt_if: fix opt_if_merge when destination branch has a jump
Fixes a case where opt_if_merge created code like:
if (...) {
break;
loop {
...
}
}
which caused opt_peel_loop_initial_if to complain that the loop pre-header
wasn't a predecessor of the loop header. This patch prevents this
(invalid, I think) unreachable code from being created.
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3496
Fixes: 4d3f6cb973 ('nir: merge some basic consecutive ifs')
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6633>
(cherry picked from commit 6cef804067)
This commit is contained in:
parent
fe13f9b8f5
commit
b617a52308
2 changed files with 8 additions and 1 deletions
|
|
@ -1066,7 +1066,7 @@
|
|||
"description": "nir/opt_if: fix opt_if_merge when destination branch has a jump",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"master_sha": null,
|
||||
"because_sha": "4d3f6cb9739dfeaf9605fcd2f5318e03acf5066e"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1274,6 +1274,13 @@ opt_if_merge(nir_if *nif)
|
|||
if (nif->condition.ssa == next_if->condition.ssa &&
|
||||
exec_list_is_empty(&next_blk->instr_list)) {
|
||||
|
||||
/* This optimization isn't made to work in this case and
|
||||
* opt_if_evaluate_condition_use will optimize it later.
|
||||
*/
|
||||
if (nir_block_ends_in_jump(nir_if_last_then_block(nif)) ||
|
||||
nir_block_ends_in_jump(nir_if_last_else_block(nif)))
|
||||
return false;
|
||||
|
||||
simple_merge_if(nif, next_if, true, true);
|
||||
simple_merge_if(nif, next_if, false, false);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue