From 4d5fce29c353666473266864b7e0569cd4d38bdc Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 26 Mar 2019 11:34:46 +0100 Subject: ac: fix ac_build_umsb() for 16-bit integer type Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen --- src/amd/common/ac_llvm_build.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/amd') diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c index 20c722e332e..fe280b31368 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -1970,7 +1970,12 @@ ac_build_umsb(struct ac_llvm_context *ctx, /* The HW returns the last bit index from MSB, but TGSI/NIR wants * the index from LSB. Invert it by doing "31 - msb". */ msb = LLVMBuildSub(ctx->builder, highest_bit, msb, ""); - msb = LLVMBuildTruncOrBitCast(ctx->builder, msb, ctx->i32, ""); + + if (bitsize == 64) { + msb = LLVMBuildTrunc(ctx->builder, msb, ctx->i32, ""); + } else if (bitsize == 16) { + msb = LLVMBuildSExt(ctx->builder, msb, ctx->i32, ""); + } /* check for zero */ return LLVMBuildSelect(ctx->builder, -- cgit v1.2.3