Mesa (master): draw: re-order optimization passes depending on LLVM version , 32/64-bit

Brian Paul brianp at kemper.freedesktop.org
Thu Jul 22 22:09:42 UTC 2010


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

Author: Brian Paul <brianp at vmware.com>
Date:   Thu Jul 22 16:07:18 2010 -0600

draw: re-order optimization passes depending on LLVM version, 32/64-bit

This is a work-around for an apparent bug in LLVM seen with piglit's
glsl-vs-sqrt-zero test.

---

 src/gallium/auxiliary/draw/draw_llvm.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 1ee8769..19f96c3 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -238,9 +238,22 @@ draw_llvm_create(struct draw_context *draw)
       /* These are the passes currently listed in llvm-c/Transforms/Scalar.h,
        * but there are more on SVN. */
       /* TODO: Add more passes */
+
       LLVMAddCFGSimplificationPass(llvm->pass);
-      LLVMAddPromoteMemoryToRegisterPass(llvm->pass);
-      LLVMAddConstantPropagationPass(llvm->pass);
+
+      if (HAVE_LLVM >= 0x207 && sizeof(void*) == 4) {
+         /* For LLVM >= 2.7 and 32-bit build, use this order of passes to
+          * avoid generating bad code.
+          * Test with piglit glsl-vs-sqrt-zero test.
+          */
+         LLVMAddConstantPropagationPass(llvm->pass);
+         LLVMAddPromoteMemoryToRegisterPass(llvm->pass);
+      }
+      else {
+         LLVMAddPromoteMemoryToRegisterPass(llvm->pass);
+         LLVMAddConstantPropagationPass(llvm->pass);
+      }
+
       if(util_cpu_caps.has_sse4_1) {
          /* FIXME: There is a bug in this pass, whereby the combination of fptosi
           * and sitofp (necessary for trunc/floor/ceil/round implementation)




More information about the mesa-commit mailing list