[Mesa-dev] [PATCH] glsl: fix glsl optimization infinite loop from copy_propagation_elements

Andy Clayton q3aiml at gmail.com
Thu Jan 5 19:17:53 PST 2012


Fixes a possible infinite loop in glsl optimization due to interaction
between copy_propagation_elements and swizzle_swizzle. This approach is
based on handle_rvalue appearing to already handle a swizzle's
referenced value. As a result it does not seem correct to also call
handle_rvalue with the referenced value, which this patch fixes.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=34006
---
 src/glsl/opt_copy_propagation_elements.cpp |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/glsl/opt_copy_propagation_elements.cpp b/src/glsl/opt_copy_propagation_elements.cpp
index a91e624..be446bc 100644
--- a/src/glsl/opt_copy_propagation_elements.cpp
+++ b/src/glsl/opt_copy_propagation_elements.cpp
@@ -108,6 +108,7 @@ public:
    virtual ir_visitor_status visit_leave(class ir_assignment *);
    virtual ir_visitor_status visit_enter(class ir_call *);
    virtual ir_visitor_status visit_enter(class ir_if *);
+   virtual ir_visitor_status visit_leave(class ir_swizzle *);
 
    void handle_rvalue(ir_rvalue **rvalue);
 
@@ -179,6 +180,15 @@ ir_copy_propagation_elements_visitor::visit_leave(ir_assignment *ir)
    return visit_continue;
 }
 
+ir_visitor_status
+ir_copy_propagation_elements_visitor::visit_leave(ir_swizzle *ir)
+{
+   /* Don't visit the values of swizzles since they are handled while
+    * visiting the swizzle itself.
+    */
+   return visit_continue;
+}
+
 /**
  * Replaces dereferences of ACP RHS variables with ACP LHS variables.
  *
-- 
1.7.5.4



More information about the mesa-dev mailing list