ac/llvm: set !fpmath 3.0 for llvm.sqrt

LLVM will be changed to increase precision with additional instructions,
which we don't want.

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25492>
This commit is contained in:
Marek Olšák
2023-08-02 20:24:04 -04:00
committed by Marge Bot
parent 476529a692
commit 2d928c7fee
3 changed files with 8 additions and 2 deletions
+5 -2
View File
@@ -100,12 +100,15 @@ void ac_llvm_context_init(struct ac_llvm_context *ctx, struct ac_llvm_compiler *
ctx->i1true = LLVMConstInt(ctx->i1, 1, false);
ctx->range_md_kind = LLVMGetMDKindIDInContext(ctx->context, "range", 5);
ctx->invariant_load_md_kind = LLVMGetMDKindIDInContext(ctx->context, "invariant.load", 14);
ctx->uniform_md_kind = LLVMGetMDKindIDInContext(ctx->context, "amdgpu.uniform", 14);
ctx->fpmath_md_kind = LLVMGetMDKindIDInContext(ctx->context, "fpmath", 6);
ctx->empty_md = LLVMMDNodeInContext(ctx->context, NULL, 0);
LLVMValueRef three = LLVMConstReal(ctx->f32, 3);
ctx->three_md = LLVMMDNodeInContext(ctx->context, &three, 1);
ctx->flow = calloc(1, sizeof(*ctx->flow));
ctx->ring_offsets_index = INT32_MAX;
+2
View File
@@ -121,7 +121,9 @@ struct ac_llvm_context {
unsigned range_md_kind;
unsigned invariant_load_md_kind;
unsigned uniform_md_kind;
unsigned fpmath_md_kind;
LLVMValueRef empty_md;
LLVMValueRef three_md;
const struct radeon_info *info;
enum amd_gfx_level gfx_level;
+1
View File
@@ -801,6 +801,7 @@ static bool visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
case nir_op_fsqrt:
result =
emit_intrin_1f_param(&ctx->ac, "llvm.sqrt", ac_to_float_type(&ctx->ac, def_type), src[0]);
LLVMSetMetadata(result, ctx->ac.fpmath_md_kind, ctx->ac.three_md);
break;
case nir_op_fexp2:
result =