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

index d27ef0de04192d714e4a78de3e36616d18758fcb..e7eb5f833b6dbdad6900d7716187803da90d5a04 100644 (file)
@@ -591,7 +591,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, "");