llvmpipe: fix broken lp_build_abs()
authorBrian Paul <brianp@vmware.com>
Mon, 14 Dec 2009 22:24:31 +0000 (15:24 -0700)
committerJosé Fonseca <jfonseca@vmware.com>
Wed, 16 Dec 2009 15:06:16 +0000 (15:06 +0000)
src/gallium/drivers/llvmpipe/lp_bld_arit.c

index 847c2a34b1ff4af58e598c3b8c35843105322bfa..eea6b5d6a5c9d2d1002fa9ff5b6edac8dba0c07c 100644 (file)
@@ -629,7 +629,8 @@ lp_build_abs(struct lp_build_context *bld,
    if(type.floating) {
       /* Mask out the sign bit */
       LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
-      LLVMValueRef mask = lp_build_int_const_scalar(type, ((unsigned long long)1 << type.width) - 1);
+      unsigned long absMask = ~(1 << (type.width - 1));
+      LLVMValueRef mask = lp_build_int_const_scalar(type, ((unsigned long long) absMask));
       a = LLVMBuildBitCast(bld->builder, a, int_vec_type, "");
       a = LLVMBuildAnd(bld->builder, a, mask, "");
       a = LLVMBuildBitCast(bld->builder, a, vec_type, "");