[Mesa-dev] [PATCH 09/10] nir: evaluate loop terminator ior use
Timothy Arceri
tarceri at itsqueeze.com
Wed Jul 11 06:48:16 UTC 2018
Here we replace one side of the ior with NIR_TRUE if the src is a
loop terminators condition that we know can only be true.
No shader-db change.
---
src/compiler/nir/nir_opt_if.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/compiler/nir/nir_opt_if.c b/src/compiler/nir/nir_opt_if.c
index 83f2141dff6..7b8085452ce 100644
--- a/src/compiler/nir/nir_opt_if.c
+++ b/src/compiler/nir/nir_opt_if.c
@@ -505,9 +505,31 @@ opt_if_evaluate_condition_use_loop_terminator(nir_if *nif, nir_loop *loop,
/* Evaluate any uses of the loop terminator condition */
assert(nif->condition.is_ssa);
nir_foreach_use_safe(use_src, nif->condition.ssa) {
- progress =
- evaluate_term_condition_use(prev_block->index, after_loop->index,
- nir_boolean, use_src, mem_ctx, false);
+ nir_instr *parent_instr = use_src->parent_instr;
+ if (nir_boolean == NIR_TRUE &&
+ parent_instr->type == nir_instr_type_alu &&
+ nir_instr_as_alu(parent_instr)->op == nir_op_ior) {
+
+ nir_alu_instr *alu = nir_instr_as_alu(parent_instr);
+
+ nir_foreach_use_safe(or_use, &alu->dest.dest.ssa) {
+ progress =
+ evaluate_term_condition_use(prev_block->index,
+ after_loop->index, NIR_TRUE,
+ or_use, mem_ctx, false);
+ }
+
+ nir_foreach_if_use_safe(or_use, &alu->dest.dest.ssa) {
+ progress =
+ evaluate_term_condition_use(prev_block->index,
+ after_loop->index, NIR_TRUE,
+ or_use, mem_ctx, true);
+ }
+ } else {
+ progress =
+ evaluate_term_condition_use(prev_block->index, after_loop->index,
+ nir_boolean, use_src, mem_ctx, false);
+ }
}
nir_foreach_if_use_safe(use_src, nif->condition.ssa) {
--
2.17.1
More information about the mesa-dev
mailing list