From e3edc6029b253090c04c34b6bea59eedd14524f4 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 21 Apr 2025 13:38:01 +0200 Subject: [PATCH] ac/llvm: use mul24 intrinsics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the current code in clpeak LLVM ended up generating v_mad_u64_u32 instructions, with this we get nice v_mad_u32_s24 ones instead and an 4x performance increase in the int24 benchmark. Suggested-by: Marek Olšák Reviewed-by: Marek Olšák Part-of: --- src/amd/llvm/ac_nir_to_llvm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c index 714dfe39e4d..37deb55bd06 100644 --- a/src/amd/llvm/ac_nir_to_llvm.c +++ b/src/amd/llvm/ac_nir_to_llvm.c @@ -612,9 +612,13 @@ static bool visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr) else result = LLVMBuildSub(ctx->ac.builder, src[0], src[1], ""); break; - case nir_op_imul: case nir_op_imul24_relaxed: + result = ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.mul.i24", ctx->ac.i32, src, 2, 0); + break; case nir_op_umul24_relaxed: + result = ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.mul.u24", ctx->ac.i32, src, 2, 0); + break; + case nir_op_imul: if (instr->no_unsigned_wrap) result = LLVMBuildNUWMul(ctx->ac.builder, src[0], src[1], ""); else if (instr->no_signed_wrap)