[Mesa-dev] [PATCH 3/3] gallivm: Use llvm.fabs.

Roland Scheidegger sroland at vmware.com
Sun Apr 3 15:06:16 UTC 2016


Am 03.04.2016 um 12:24 schrieb Jose Fonseca:
> Exactly the same code.
> ---
>  src/gallium/auxiliary/gallivm/lp_bld_arit.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
> index 1277743..587c83a 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
> @@ -1492,14 +1492,9 @@ lp_build_abs(struct lp_build_context *bld,
>        return a;
>  
>     if(type.floating) {
> -      /* Mask out the sign bit */
> -      LLVMTypeRef int_vec_type = lp_build_int_vec_type(bld->gallivm, type);
> -      unsigned long long absMask = ~(1ULL << (type.width - 1));
> -      LLVMValueRef mask = lp_build_const_int_vec(bld->gallivm, type, ((unsigned long long) absMask));
> -      a = LLVMBuildBitCast(builder, a, int_vec_type, "");
> -      a = LLVMBuildAnd(builder, a, mask, "");
> -      a = LLVMBuildBitCast(builder, a, vec_type, "");
> -      return a;
> +      char intrinsic[32];
> +      util_snprintf(intrinsic, sizeof intrinsic, "llvm.fabs.v%uf%u", type.length, type.width);
> +      return lp_build_intrinsic_unary(builder, intrinsic, vec_type, a);
>     }
>  
>     if(type.width*type.length == 128 && util_cpu_caps.has_ssse3) {
> 

Looks like fabs was new with llvm 3.2, which is probably why we came up
with our own implementation. But it can go now.

For 1/3 and 3/3:
Reviewed-by: Roland Scheidegger <sroland at vmware.com>



More information about the mesa-dev mailing list