draw: re-order optimization passes depending on LLVM version, 32/64-bit
authorBrian Paul <brianp@vmware.com>
Thu, 22 Jul 2010 22:07:18 +0000 (16:07 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 22 Jul 2010 22:09:03 +0000 (16:09 -0600)
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

index 1ee87697b4af6ebebaf0510b21ca4149efd0e4e2..19f96c37ab42dd9d76d2ec9452c7253df5770864 100644 (file)
@@ -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)