gallivm/nir: handle 16-bit exp/lod using intrinsics.
This just passes the 16-bit float versions to the llvm intrinsics Reviewed-by: Roland Scheidegger <sroland@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11816>
This commit is contained in:
@@ -3227,6 +3227,13 @@ lp_build_exp2(struct lp_build_context *bld,
|
||||
LLVMValueRef expfpart = NULL;
|
||||
LLVMValueRef res = NULL;
|
||||
|
||||
if (type.floating && type.width == 16) {
|
||||
char intrinsic[32];
|
||||
lp_format_intrinsic(intrinsic, sizeof intrinsic, "llvm.exp2", vec_type);
|
||||
LLVMValueRef args[] = { x };
|
||||
return lp_build_intrinsic(builder, intrinsic, vec_type, args, 1, 0);
|
||||
}
|
||||
|
||||
assert(lp_check_value(bld->type, x));
|
||||
|
||||
/* TODO: optimize the constant case */
|
||||
@@ -3408,6 +3415,15 @@ lp_build_log2_approx(struct lp_build_context *bld,
|
||||
LLVMValueRef p_z = NULL;
|
||||
LLVMValueRef res = NULL;
|
||||
|
||||
if (bld->type.width == 16) {
|
||||
char intrinsic[32];
|
||||
lp_format_intrinsic(intrinsic, sizeof intrinsic, "llvm.log2", bld->vec_type);
|
||||
LLVMValueRef args[] = { x };
|
||||
if (p_log2)
|
||||
*p_log2 = lp_build_intrinsic(builder, intrinsic, bld->vec_type, args, 1, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
assert(lp_check_value(bld->type, x));
|
||||
|
||||
if(p_exp || p_floor_log2 || p_log2) {
|
||||
|
||||
@@ -704,7 +704,7 @@ static LLVMValueRef do_alu_action(struct lp_build_nir_context *bld_base,
|
||||
result = fcmp32(bld_base, PIPE_FUNC_EQUAL, src_bit_size[0], src);
|
||||
break;
|
||||
case nir_op_fexp2:
|
||||
result = lp_build_exp2(&bld_base->base, src[0]);
|
||||
result = lp_build_exp2(get_flt_bld(bld_base, src_bit_size[0]), src[0]);
|
||||
break;
|
||||
case nir_op_ffloor:
|
||||
result = lp_build_floor(get_flt_bld(bld_base, src_bit_size[0]), src[0]);
|
||||
@@ -734,7 +734,7 @@ static LLVMValueRef do_alu_action(struct lp_build_nir_context *bld_base,
|
||||
result = lp_build_isfinite(get_flt_bld(bld_base, src_bit_size[0]), src[0]);
|
||||
break;
|
||||
case nir_op_flog2:
|
||||
result = lp_build_log2_safe(&bld_base->base, src[0]);
|
||||
result = lp_build_log2_safe(get_flt_bld(bld_base, src_bit_size[0]), src[0]);
|
||||
break;
|
||||
case nir_op_flt:
|
||||
case nir_op_flt32:
|
||||
|
||||
Reference in New Issue
Block a user