summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2017-02-24 15:27:07 -0800
committerMatt Turner <[email protected]>2017-03-23 14:34:43 -0700
commit0012a6144aa32e907aa27e8a9fb42472f01066ea (patch)
tree98711195da3f7a2f98bf6e602530cb3fa46bcad5
parentc597f87739bae7d0d386381417a0aba6bbc39fe2 (diff)
nir: Return progress from nir_lower_doubles().
Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/compiler/nir/nir.h2
-rw-r--r--src/compiler/nir/nir_lower_double_ops.c62
2 files changed, 42 insertions, 22 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 910352dba07..1b9e17fe89d 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2567,7 +2567,7 @@ typedef enum {
nir_lower_dmod = (1 << 8)
} nir_lower_doubles_options;
-void nir_lower_doubles(nir_shader *shader, nir_lower_doubles_options options);
+bool nir_lower_doubles(nir_shader *shader, nir_lower_doubles_options options);
void nir_lower_64bit_pack(nir_shader *shader);
bool nir_normalize_cubemap_coords(nir_shader *shader);
diff --git a/src/compiler/nir/nir_lower_double_ops.c b/src/compiler/nir/nir_lower_double_ops.c
index 00eeb89b1bd..b3543bc6963 100644
--- a/src/compiler/nir/nir_lower_double_ops.c
+++ b/src/compiler/nir/nir_lower_double_ops.c
@@ -456,61 +456,61 @@ lower_mod(nir_builder *b, nir_ssa_def *src0, nir_ssa_def *src1)
nir_imm_double(b, 0.0));
}
-static void
+static bool
lower_doubles_instr(nir_alu_instr *instr, nir_lower_doubles_options options)
{
assert(instr->dest.dest.is_ssa);
if (instr->dest.dest.ssa.bit_size != 64)
- return;
+ return false;
switch (instr->op) {
case nir_op_frcp:
if (!(options & nir_lower_drcp))
- return;
+ return false;
break;
case nir_op_fsqrt:
if (!(options & nir_lower_dsqrt))
- return;
+ return false;
break;
case nir_op_frsq:
if (!(options & nir_lower_drsq))
- return;
+ return false;
break;
case nir_op_ftrunc:
if (!(options & nir_lower_dtrunc))
- return;
+ return false;
break;
case nir_op_ffloor:
if (!(options & nir_lower_dfloor))
- return;
+ return false;
break;
case nir_op_fceil:
if (!(options & nir_lower_dceil))
- return;
+ return false;
break;
case nir_op_ffract:
if (!(options & nir_lower_dfract))
- return;
+ return false;
break;
case nir_op_fround_even:
if (!(options & nir_lower_dround_even))
- return;
+ return false;
break;
case nir_op_fmod:
if (!(options & nir_lower_dmod))
- return;
+ return false;
break;
default:
- return;
+ return false;
}
nir_builder bld;
@@ -560,20 +560,40 @@ lower_doubles_instr(nir_alu_instr *instr, nir_lower_doubles_options options)
nir_ssa_def_rewrite_uses(&instr->dest.dest.ssa, nir_src_for_ssa(result));
nir_instr_remove(&instr->instr);
+ return true;
}
-void
+static bool
+nir_lower_doubles_impl(nir_function_impl *impl,
+ nir_lower_doubles_options options)
+{
+ bool progress = false;
+
+ nir_foreach_block(block, impl) {
+ nir_foreach_instr_safe(instr, block) {
+ if (instr->type == nir_instr_type_alu)
+ progress |= lower_doubles_instr(nir_instr_as_alu(instr),
+ options);
+ }
+ }
+
+ if (progress)
+ nir_metadata_preserve(impl, nir_metadata_block_index |
+ nir_metadata_dominance);
+
+ return progress;
+}
+
+bool
nir_lower_doubles(nir_shader *shader, nir_lower_doubles_options options)
{
+ bool progress = false;
+
nir_foreach_function(function, shader) {
- if (!function->impl)
- continue;
-
- nir_foreach_block(block, function->impl) {
- nir_foreach_instr_safe(instr, block) {
- if (instr->type == nir_instr_type_alu)
- lower_doubles_instr(nir_instr_as_alu(instr), options);
- }
+ if (function->impl) {
+ progress |= nir_lower_doubles_impl(function->impl, options);
}
}
+
+ return progress;
}