summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2019-01-14 15:12:36 -0800
committerIan Romanick <[email protected]>2019-02-08 10:37:06 -0800
commit0c0c69729b6d72a5297122856c8fe48510e90764 (patch)
tree2119357812abe07c71030f4d5f6ccfb875b708f6 /src/compiler/nir
parent8d8f80af3a17354508f2ec9d6559c915d5be351d (diff)
nir: Select phi nodes using prev_block instead of continue_block
This simplifies some changes coming later. Fixes: 8fb8ebfbb05 ("intel/compiler: More peephole select") Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir_opt_if.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c
index c54d4a20f4c..0e7cc56395e 100644
--- a/src/compiler/nir/nir_opt_if.c
+++ b/src/compiler/nir/nir_opt_if.c
@@ -53,7 +53,7 @@ find_continue_block(nir_loop *loop)
*/
static bool
phi_has_constant_from_outside_and_one_from_inside_loop(nir_phi_instr *phi,
- const nir_block *continue_block,
+ const nir_block *entry_block,
uint32_t *entry_val,
uint32_t *continue_val)
{
@@ -69,7 +69,7 @@ phi_has_constant_from_outside_and_one_from_inside_loop(nir_phi_instr *phi,
if (!const_src)
return false;
- if (src->pred == continue_block) {
+ if (src->pred != entry_block) {
*continue_val = const_src->u32[0];
} else {
*entry_val = const_src->u32[0];
@@ -137,7 +137,7 @@ static bool
opt_peel_loop_initial_if(nir_loop *loop)
{
nir_block *header_block = nir_loop_first_block(loop);
- MAYBE_UNUSED nir_block *prev_block =
+ nir_block *const prev_block =
nir_cf_node_as_block(nir_cf_node_prev(&loop->cf_node));
/* It would be insane if this were not true */
@@ -150,8 +150,6 @@ opt_peel_loop_initial_if(nir_loop *loop)
if (header_block->predecessors->entries != 2)
return false;
- nir_block *continue_block = find_continue_block(loop);
-
nir_cf_node *if_node = nir_cf_node_next(&header_block->cf_node);
if (!if_node || if_node->type != nir_cf_node_if)
return false;
@@ -169,7 +167,7 @@ opt_peel_loop_initial_if(nir_loop *loop)
uint32_t entry_val = 0, continue_val = 0;
if (!phi_has_constant_from_outside_and_one_from_inside_loop(cond_phi,
- continue_block,
+ prev_block,
&entry_val,
&continue_val))
return false;
@@ -236,14 +234,15 @@ opt_peel_loop_initial_if(nir_loop *loop)
nir_after_cf_list(entry_list));
nir_cf_reinsert(&tmp, nir_before_cf_node(&loop->cf_node));
- nir_cf_reinsert(&header, nir_after_block_before_jump(continue_block));
-
- /* Get continue block again as the previous reinsert might have removed the block. */
- continue_block = find_continue_block(loop);
+ nir_cf_reinsert(&header,
+ nir_after_block_before_jump(find_continue_block(loop)));
nir_cf_extract(&tmp, nir_before_cf_list(continue_list),
nir_after_cf_list(continue_list));
- nir_cf_reinsert(&tmp, nir_after_block_before_jump(continue_block));
+
+ /* Get continue block again as the previous reinsert might have removed the block. */
+ nir_cf_reinsert(&tmp,
+ nir_after_block_before_jump(find_continue_block(loop)));
nir_cf_node_remove(&nif->cf_node);