[Mesa-dev] [PATCH] glsl: mark variable as loop constant when it is set read only

Tapani Pälli tapani.palli at intel.com
Tue Sep 9 04:56:06 PDT 2014


Patch modifies is_loop_constant() to take advantage of 'read_only' bit
in ir_variable to detect a loop constant. Variables marked read-only
are loop constant like mentioned by a comment in the function.

Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82537
---
 src/glsl/loop_analysis.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/glsl/loop_analysis.h b/src/glsl/loop_analysis.h
index 295dc79..8e2979c 100644
--- a/src/glsl/loop_analysis.h
+++ b/src/glsl/loop_analysis.h
@@ -205,10 +205,10 @@ public:
    inline bool is_loop_constant() const
    {
       const bool is_const = (this->num_assignments == 0)
-	 || ((this->num_assignments == 1)
+	 || (((this->num_assignments == 1)
 	     && !this->conditional_or_nested_assignment
 	     && !this->read_before_write
-	     && this->rhs_clean);
+	     && this->rhs_clean) || this->var->data.read_only);
 
       /* If the RHS of *the* assignment is clean, then there must be exactly
        * one assignment of the variable.
-- 
1.9.3



More information about the mesa-dev mailing list