Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6284>
AC_FUNC_ATTR_READNONE);
}
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) {
{
if (LLVMGetTypeKind(type) == LLVMVectorTypeKind) {
LLVMValueRef ac_build_fract(struct ac_llvm_context *ctx, LLVMValueRef src0,
unsigned bitsize);
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);
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);
LLVMValueRef src0,
unsigned bitsize)
{
LLVMValueRef src0,
unsigned bitsize)
{
+ assert(ac_get_elem_bits(ctx, LLVMTypeOf(src0)) == 32);
LLVMValueRef result = LLVMBuildAnd(ctx->builder, src0,
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);
- 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:
case 32:
return result;
case 64: