summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-04-13 14:13:16 -0700
committerJason Ekstrand <[email protected]>2015-04-22 18:10:41 -0700
commit125574d1effcb3e3eda93f2b2975bc6cc606df3e (patch)
treefc560faf5adff7c42509c903c5c7a0f51e5a9428
parent296131f4674ee979a8cffe56fc61bbd42110982e (diff)
nir/lower_source_mods: Don't propagate register sources
The nir_lower_source_mods pass does a weak form of copy propagation to clean up all of the mov-with-negate's that get generated. However, we weren't properly checking that the sources were SSA and so we could end up moving a register read which is not, in general, valid. Reviewed-by: Connor Abbott <[email protected]>
-rw-r--r--src/glsl/nir/nir_lower_to_source_mods.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/glsl/nir/nir_lower_to_source_mods.c b/src/glsl/nir/nir_lower_to_source_mods.c
index d6bf77f17c1..7b4a0f65738 100644
--- a/src/glsl/nir/nir_lower_to_source_mods.c
+++ b/src/glsl/nir/nir_lower_to_source_mods.c
@@ -67,6 +67,13 @@ nir_lower_to_source_mods_block(nir_block *block, void *state)
continue;
}
+ /* We can only do a rewrite if the source we are copying is SSA.
+ * Otherwise, moving the read might invalidly reorder reads/writes
+ * on a register.
+ */
+ if (!parent->src[0].src.is_ssa)
+ continue;
+
nir_instr_rewrite_src(instr, &alu->src[i].src, parent->src[0].src);
if (alu->src[i].abs) {
/* abs trumps both neg and abs, do nothing */