Mesa (master): i965: Show opt_vector_float() and later passes in INTEL_DEBUG=optimizer.

Kenneth Graunke kwg at kemper.freedesktop.org
Sat Jan 3 09:45:39 UTC 2015


Module: Mesa
Branch: master
Commit: 9b8bd67768769b685c25e1276e053505aede5f93
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9b8bd67768769b685c25e1276e053505aede5f93

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Wed Dec 31 16:47:25 2014 -0800

i965: Show opt_vector_float() and later passes in INTEL_DEBUG=optimizer.

In order to support calling opt_vector_float() inside a condition, this
patch makes OPT() a statement expression:

https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html

We've used that elsewhere already.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

 src/mesa/drivers/dri/i965/brw_vec4.cpp |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index f389392..79368a7 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1758,7 +1758,7 @@ vec4_visitor::run()
 
    const char *stage_name = stage == MESA_SHADER_GEOMETRY ? "gs" : "vs";
 
-#define OPT(pass, args...) do {                                        \
+#define OPT(pass, args...) ({                                          \
       pass_num++;                                                      \
       bool this_progress = pass(args);                                 \
                                                                        \
@@ -1771,7 +1771,8 @@ vec4_visitor::run()
       }                                                                \
                                                                        \
       progress = progress || this_progress;                            \
-   } while (false)
+      this_progress;                                                   \
+   })
 
 
    if (unlikely(INTEL_DEBUG & DEBUG_OPTIMIZER)) {
@@ -1784,10 +1785,11 @@ vec4_visitor::run()
 
    bool progress;
    int iteration = 0;
+   int pass_num = 0;
    do {
       progress = false;
+      pass_num = 0;
       iteration++;
-      int pass_num = 0;
 
       OPT(opt_reduce_swizzle);
       OPT(dead_code_eliminate);
@@ -1798,11 +1800,13 @@ vec4_visitor::run()
       OPT(opt_register_coalesce);
    } while (progress);
 
-   if (opt_vector_float()) {
-      opt_cse();
-      opt_copy_propagation(false);
-      opt_copy_propagation(true);
-      dead_code_eliminate();
+   pass_num = 0;
+
+   if (OPT(opt_vector_float)) {
+      OPT(opt_cse);
+      OPT(opt_copy_propagation, false);
+      OPT(opt_copy_propagation, true);
+      OPT(dead_code_eliminate);
    }
 
    if (failed)




More information about the mesa-commit mailing list