Mesa (master): nir: Rename opt_undef_alu to opt_undef_csel; update comments.
Kenneth Graunke
kwg at kemper.freedesktop.org
Thu May 5 21:24:25 UTC 2016
Module: Mesa
Branch: master
Commit: 49ea7454a189d9ebfa03fddfdba9949c6eaf4caa
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=49ea7454a189d9ebfa03fddfdba9949c6eaf4caa
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Wed Apr 20 01:15:53 2016 -0700
nir: Rename opt_undef_alu to opt_undef_csel; update comments.
This better reflects what it does. I plan to add other ALU
optimizations as well, so the old name would be confusing.
In preparation for that, also move the file comments about csels
above the opt_undef_csel function, and delete the ones about there
not being other optimizations.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
---
src/compiler/nir/nir_opt_undef.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/compiler/nir/nir_opt_undef.c b/src/compiler/nir/nir_opt_undef.c
index 14459ff..ce18c2d 100644
--- a/src/compiler/nir/nir_opt_undef.c
+++ b/src/compiler/nir/nir_opt_undef.c
@@ -25,18 +25,17 @@
/** @file nir_opt_undef.c
*
- * Handles optimization of operations involving ssa_undef. For now, we just
- * make sure that csels between undef and some other value just give the other
- * value (on the assumption that the condition's going to be choosing the
- * defined value). This reduces work after if flattening when each side of
- * the if is defining a variable.
- *
- * Some day, we may find some use for making other operations consuming an
- * undef arg output undef, but I don't know of any cases currently.
+ * Handles optimization of operations involving ssa_undef.
*/
+/**
+ * Turn conditional selects between an undef and some other value into a move
+ * of that other value (on the assumption that the condition's going to be
+ * choosing the defined value). This reduces work after if flattening when
+ * each side of the if is defining a variable.
+ */
static bool
-opt_undef_alu(nir_alu_instr *instr)
+opt_undef_csel(nir_alu_instr *instr)
{
if (instr->op != nir_op_bcsel && instr->op != nir_op_fcsel)
return false;
@@ -80,9 +79,11 @@ nir_opt_undef(nir_shader *shader)
if (function->impl) {
nir_foreach_block(block, function->impl) {
nir_foreach_instr_safe(instr, block) {
- if (instr->type == nir_instr_type_alu)
- if (opt_undef_alu(nir_instr_as_alu(instr)))
- progress = true;
+ if (instr->type == nir_instr_type_alu) {
+ nir_alu_instr *alu = nir_instr_as_alu(instr);
+
+ progress = opt_undef_csel(alu) || progress;
+ }
}
}
More information about the mesa-commit
mailing list