diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c index 6aa6ce1f7e5..f532c64b17d 100644 --- a/src/amd/llvm/ac_llvm_build.c +++ b/src/amd/llvm/ac_llvm_build.c @@ -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; diff --git a/src/amd/llvm/ac_llvm_build.h b/src/amd/llvm/ac_llvm_build.h index 00ce0a9ed39..bede3ff2e0e 100644 --- a/src/amd/llvm/ac_llvm_build.h +++ b/src/amd/llvm/ac_llvm_build.h @@ -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; diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c index 2583544040b..b0a335fb881 100644 --- a/src/amd/llvm/ac_nir_to_llvm.c +++ b/src/amd/llvm/ac_nir_to_llvm.c @@ -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 =