glsl: mark variable as loop constant when it is set read only
authorTapani Pälli <tapani.palli@intel.com>
Tue, 9 Sep 2014 11:56:06 +0000 (14:56 +0300)
committerTapani Pälli <tapani.palli@intel.com>
Thu, 11 Sep 2014 07:09:12 +0000 (10:09 +0300)
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.

v2: remove unnecessary comment (Francisco)

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82537
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/glsl/loop_analysis.h

index 295dc797c09f776943777aa37c4e599ece5c2eac..31be4f3cfa01a44cdcb4d6dcd202e60a945c2cdc 100644 (file)
@@ -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.
@@ -216,11 +216,6 @@ public:
       assert((this->rhs_clean && (this->num_assignments == 1))
             || !this->rhs_clean);
 
-      /* Variables that are marked read-only *MUST* be loop constant.
-       */
-      assert(!this->var->data.read_only
-            || (this->var->data.read_only && is_const));
-
       return is_const;
    }