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:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user