ac/llvm: fix b2f for v2f16

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6284>
This commit is contained in:
Marek Olšák
2020-09-06 03:46:59 -04:00
committed by Marge Bot
parent d9a77f9ca3
commit e8d55e6db3
3 changed files with 9 additions and 5 deletions
+1 -1
View File
@@ -2751,7 +2751,7 @@ LLVMValueRef ac_build_fract(struct ac_llvm_context *ctx, LLVMValueRef src0,
AC_FUNC_ATTR_READNONE);
}
static LLVMValueRef ac_const_uint_vec(struct ac_llvm_context *ctx, LLVMTypeRef type, uint64_t value)
LLVMValueRef ac_const_uint_vec(struct ac_llvm_context *ctx, LLVMTypeRef type, uint64_t value)
{
if (LLVMGetTypeKind(type) == LLVMVectorTypeKind) {
+1
View File
@@ -597,6 +597,7 @@ void ac_build_waitcnt(struct ac_llvm_context *ctx, unsigned wait_flags);
LLVMValueRef ac_build_fract(struct ac_llvm_context *ctx, LLVMValueRef src0,
unsigned bitsize);
LLVMValueRef ac_const_uint_vec(struct ac_llvm_context *ctx, LLVMTypeRef type, uint64_t value);
LLVMValueRef ac_build_isign(struct ac_llvm_context *ctx, LLVMValueRef src0);
LLVMValueRef ac_build_fsign(struct ac_llvm_context *ctx, LLVMValueRef src);
LLVMValueRef ac_build_bit_count(struct ac_llvm_context *ctx, LLVMValueRef src0);
+7 -4
View File
@@ -330,14 +330,17 @@ static LLVMValueRef emit_b2f(struct ac_llvm_context *ctx,
LLVMValueRef src0,
unsigned bitsize)
{
assert(ac_get_elem_bits(ctx, LLVMTypeOf(src0)) == 32);
LLVMValueRef result = LLVMBuildAnd(ctx->builder, src0,
LLVMBuildBitCast(ctx->builder, LLVMConstReal(ctx->f32, 1.0), ctx->i32, ""),
ac_const_uint_vec(ctx, LLVMTypeOf(src0), 0x3f800000),
"");
result = LLVMBuildBitCast(ctx->builder, result, ctx->f32, "");
result = ac_to_float(ctx, result);
switch (bitsize) {
case 16:
return LLVMBuildFPTrunc(ctx->builder, result, ctx->f16, "");
case 16: {
bool vec2 = LLVMGetTypeKind(LLVMTypeOf(result)) == LLVMVectorTypeKind;
return LLVMBuildFPTrunc(ctx->builder, result, vec2 ? ctx->v2f16 : ctx->f16, "");
}
case 32:
return result;
case 64: