ac/llvm: add ac_build_canonicalize() helper

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
This commit is contained in:
Samuel Pitoiset
2019-10-14 14:23:35 +02:00
parent 3ad6154f4e
commit d94bd4e512
3 changed files with 33 additions and 6 deletions

View File

@@ -4369,6 +4369,31 @@ ac_build_frexp_mant(struct ac_llvm_context *ctx, LLVMValueRef src0,
AC_FUNC_ATTR_READNONE);
}
LLVMValueRef
ac_build_canonicalize(struct ac_llvm_context *ctx, LLVMValueRef src0,
unsigned bitsize)
{
LLVMTypeRef type;
char *intr;
if (bitsize == 16) {
intr = "llvm.canonicalize.f16";
type = ctx->f16;
} else if (bitsize == 32) {
intr = "llvm.canonicalize.f32";
type = ctx->f32;
} else if (bitsize == 64) {
intr = "llvm.canonicalize.f64";
type = ctx->f64;
}
LLVMValueRef params[] = {
src0,
};
return ac_build_intrinsic(ctx, intr, type, params, 1,
AC_FUNC_ATTR_READNONE);
}
/*
* this takes an I,J coordinate pair,
* and works out the X and Y derivatives.

View File

@@ -715,6 +715,10 @@ LLVMValueRef
ac_build_frexp_mant(struct ac_llvm_context *ctx, LLVMValueRef src0,
unsigned bitsize);
LLVMValueRef
ac_build_canonicalize(struct ac_llvm_context *ctx, LLVMValueRef src0,
unsigned bitsize);
LLVMValueRef
ac_build_ddxy_interp(struct ac_llvm_context *ctx, LLVMValueRef interp_ij);

View File

@@ -740,9 +740,8 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
if (ctx->ac.chip_class < GFX9 &&
instr->dest.dest.ssa.bit_size == 32) {
/* Only pre-GFX9 chips do not flush denorms. */
result = emit_intrin_1f_param(&ctx->ac, "llvm.canonicalize",
ac_to_float_type(&ctx->ac, def_type),
result);
result = ac_build_canonicalize(&ctx->ac, result,
instr->dest.dest.ssa.bit_size);
}
break;
case nir_op_fmin:
@@ -751,9 +750,8 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
if (ctx->ac.chip_class < GFX9 &&
instr->dest.dest.ssa.bit_size == 32) {
/* Only pre-GFX9 chips do not flush denorms. */
result = emit_intrin_1f_param(&ctx->ac, "llvm.canonicalize",
ac_to_float_type(&ctx->ac, def_type),
result);
result = ac_build_canonicalize(&ctx->ac, result,
instr->dest.dest.ssa.bit_size);
}
break;
case nir_op_ffma: