Mesa (staging/20.1): glsl: fix incorrect optimisation in opt_constant_variable()
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Jun 13 21:15:15 UTC 2020
Module: Mesa
Branch: staging/20.1
Commit: cd6c24f649ed104a1f59212313ceff0ecc4ab087
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd6c24f649ed104a1f59212313ceff0ecc4ab087
Author: Timothy Arceri <tarceri at itsqueeze.com>
Date: Wed Jun 10 15:19:22 2020 +1000
glsl: fix incorrect optimisation in opt_constant_variable()
When handling function inputs the optimisation pass incorrectly
assumes the inputs are undefined. Here we simply change things to
assume inputs have always been assigned a value. Any further
optimisations will be taken care of once function inlining takes
place.
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2984
Fixes: 65122e9e8038 ("ir_constant_variable: New pass to mark constant-assigned variables constant.")
Reviewed-by: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5413>
(cherry picked from commit b33f811068596c2764f6396a885f7aab7d7d411c)
---
.pick_status.json | 2 +-
src/compiler/glsl/opt_constant_variable.cpp | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/.pick_status.json b/.pick_status.json
index b93dfce6ff9..6aa6c93c8f5 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -796,7 +796,7 @@
"description": "glsl: fix incorrect optimisation in opt_constant_variable()",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "65122e9e8038488e8c586eb609e434a90188de27"
},
diff --git a/src/compiler/glsl/opt_constant_variable.cpp b/src/compiler/glsl/opt_constant_variable.cpp
index cc2760f5609..3f2b6a04b9f 100644
--- a/src/compiler/glsl/opt_constant_variable.cpp
+++ b/src/compiler/glsl/opt_constant_variable.cpp
@@ -165,6 +165,15 @@ ir_constant_variable_visitor::visit_enter(ir_call *ir)
entry = get_assignment_entry(var, this->ht);
entry->assignment_count++;
}
+
+ /* We don't know if the variable passed to this function has been
+ * assigned a value or if it is undefined, so for now we always assume
+ * it has been assigned a value. Once functions have been inlined any
+ * further potential optimisations will be taken care of.
+ */
+ struct assignment_entry *entry;
+ entry = get_assignment_entry(param, this->ht);
+ entry->assignment_count++;
}
/* Mark the return storage as having been assigned to */
More information about the mesa-commit
mailing list