llvmpipe: Workaround for bug in llvm 2.5.
authorJosé Fonseca <jfonseca@vmware.com>
Tue, 29 Sep 2009 16:26:20 +0000 (17:26 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Tue, 29 Sep 2009 16:28:15 +0000 (17:28 +0100)
The combination of fptosi
and sitofp (necessary for trunc/floor/ceil/round implementation)
somehow becomes invalid code.

Skip the instruction combining pass when SSE4.1 is not available.

src/gallium/drivers/llvmpipe/lp_jit.c

index 5d2cf01e5bcbb459b15dbe3818882cc3b1aa5d17..1126bf90b96b03e9a0d770f04753b481ccda2dc6 100644 (file)
@@ -150,6 +150,12 @@ lp_jit_screen_init(struct llvmpipe_screen *screen)
 
    util_cpu_detect();
 
+#if 0
+   /* For simulating less capable machines */
+   util_cpu_caps.has_sse3 = 0;
+   util_cpu_caps.has_sse4_1 = 0;
+#endif
+
 #ifdef LLVM_NATIVE_ARCH
    LLVMLinkInJIT();
    LLVMInitializeNativeTarget();
@@ -171,8 +177,15 @@ lp_jit_screen_init(struct llvmpipe_screen *screen)
    LLVMAddTargetData(screen->target, screen->pass);
    /* These are the passes currently listed in llvm-c/Transforms/Scalar.h,
     * but there are more on SVN. */
+   /* TODO: Add more passes */
    LLVMAddConstantPropagationPass(screen->pass);
-   LLVMAddInstructionCombiningPass(screen->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)
+       * somehow becomes invalid code.
+       */
+      LLVMAddInstructionCombiningPass(screen->pass);
+   }
    LLVMAddPromoteMemoryToRegisterPass(screen->pass);
    LLVMAddGVNPass(screen->pass);
    LLVMAddCFGSimplificationPass(screen->pass);