summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/llvmpipe/lp_bld_conv.c
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2009-09-29 13:58:58 +0100
committerJosé Fonseca <jfonseca@vmware.com>2009-09-29 13:59:16 +0100
commit7cda8ea44c2b65265cefa79bd29a4990ac81cee6 (patch)
tree10203fd989811dc23a13fbed4d47511e3f2b88fe /src/gallium/drivers/llvmpipe/lp_bld_conv.c
parenta81fb2a0d2c9a94fa362705edd1281fa7699d093 (diff)
llvmpipe: Emit SSE intrinsics based on runtime cpu capability check.
Note that llvmpipe still doesn't run on any processor yet: if you don't have a recent processor with SSE4.1 you will still likely end up hitting a code path for which a generic non-sse4 version is not implemented yet.
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_bld_conv.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_conv.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_conv.c b/src/gallium/drivers/llvmpipe/lp_bld_conv.c
index 186cac70f6..20c8710214 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_conv.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_conv.c
@@ -63,6 +63,7 @@
#include "util/u_debug.h"
#include "util/u_math.h"
+#include "util/u_cpu_detect.h"
#include "lp_bld_type.h"
#include "lp_bld_const.h"
@@ -334,8 +335,7 @@ lp_build_pack2(LLVMBuilderRef builder,
assert(!src_type.floating);
assert(!dst_type.floating);
-#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
- if(src_type.width * src_type.length == 128) {
+ if(util_cpu_caps.has_sse2 && src_type.width * src_type.length == 128) {
/* All X86 non-interleaved pack instructions all take signed inputs and
* saturate them, so saturate beforehand. */
if(!src_type.sign && !clamped) {
@@ -349,7 +349,7 @@ lp_build_pack2(LLVMBuilderRef builder,
switch(src_type.width) {
case 32:
- if(dst_type.sign)
+ if(dst_type.sign || !util_cpu_caps.has_sse4_1)
res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packssdw.128", src_vec_type, lo, hi);
else
/* PACKUSDW is the only instrinsic with a consistent signature */
@@ -372,7 +372,6 @@ lp_build_pack2(LLVMBuilderRef builder,
res = LLVMBuildBitCast(builder, res, dst_vec_type, "");
return res;
}
-#endif
lo = LLVMBuildBitCast(builder, lo, dst_vec_type, "");
hi = LLVMBuildBitCast(builder, hi, dst_vec_type, "");