From 96afed314b107445b3b33ba9429e39fec5d33207 Mon Sep 17 00:00:00 2001 From: Ganesh Belgur Ramachandra Date: Wed, 27 May 2026 08:58:09 +0000 Subject: [PATCH 1/2] amd/llvm: fix target feature setting (DumpCode -> dumpcode) Refer changes made to AMDGPU backend of llvm-project in commit 4b1cfc5d7c606ece125d1e0ef6d13e0289553200 --- src/amd/llvm/ac_llvm_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/amd/llvm/ac_llvm_util.c b/src/amd/llvm/ac_llvm_util.c index b8e7fa690f0..b606b988a39 100644 --- a/src/amd/llvm/ac_llvm_util.c +++ b/src/amd/llvm/ac_llvm_util.c @@ -148,7 +148,7 @@ void ac_llvm_set_target_features(LLVMValueRef F, struct ac_llvm_context *ctx, bo { char features[2048]; - snprintf(features, sizeof(features), "+DumpCode%s%s", + snprintf(features, sizeof(features), "+dumpcode%s%s", /* Wave32 is the default. */ ctx->gfx_level >= GFX10 && ctx->wave_size == 64 ? ",+wavefrontsize64,-wavefrontsize32" : "", From 2d0df2deebade7adf02f0066e03043cfdeef1d44 Mon Sep 17 00:00:00 2001 From: Ganesh Belgur Ramachandra Date: Wed, 27 May 2026 13:19:56 +0000 Subject: [PATCH 2/2] amd/llvm: fix LLVM asserts for integer constants After LLVM APIint's refactor, integer signedness needs to be handled explicitly. --- src/amd/llvm/ac_llvm_build.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c index 2e2bc1e1750..be1e731c237 100644 --- a/src/amd/llvm/ac_llvm_build.c +++ b/src/amd/llvm/ac_llvm_build.c @@ -1192,7 +1192,7 @@ void ac_set_range_metadata(struct ac_llvm_context *ctx, LLVMValueRef value, unsi LLVMValueRef ac_get_thread_id(struct ac_llvm_context *ctx) { - return ac_build_mbcnt(ctx, LLVMConstInt(ctx->iN_wavemask, ~0ull, 0)); + return ac_build_mbcnt(ctx, LLVMConstAllOnes(ctx->iN_wavemask)); } /* @@ -1822,7 +1822,7 @@ LLVMValueRef ac_build_cvt_pk_i16(struct ac_llvm_context *ctx, LLVMValueRef args[ assert(bits == 8 || bits == 10 || bits == 16); LLVMValueRef max_rgb = LLVMConstInt(ctx->i32, bits == 8 ? 127 : bits == 10 ? 511 : 32767, 0); - LLVMValueRef min_rgb = LLVMConstInt(ctx->i32, bits == 8 ? -128 : bits == 10 ? -512 : -32768, 0); + LLVMValueRef min_rgb = LLVMConstInt(ctx->i32, bits == 8 ? -128 : bits == 10 ? -512 : -32768, 1); LLVMValueRef max_alpha = bits != 10 ? max_rgb : ctx->i32_1; LLVMValueRef min_alpha = bits != 10 ? min_rgb : LLVMConstInt(ctx->i32, -2, 0); @@ -1997,8 +1997,14 @@ LLVMValueRef ac_build_fsat(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef ac_const_uint_vec(struct ac_llvm_context *ctx, LLVMTypeRef type, uint64_t value) { + bool isVector = (LLVMGetTypeKind(type) == LLVMVectorTypeKind); + LLVMTypeRef ty = (isVector ? LLVMGetElementType(type) : type); - if (LLVMGetTypeKind(type) == LLVMVectorTypeKind) { + if (LLVMGetIntTypeWidth(ty) < 64) { + value = value & ((1lu << LLVMGetIntTypeWidth(ty)) - 1); + } + + if (isVector) { LLVMValueRef scalar = LLVMConstInt(LLVMGetElementType(type), value, 0); unsigned vec_size = LLVMGetVectorSize(type); LLVMValueRef *scalars = alloca(vec_size * sizeof(LLVMValueRef)); @@ -2212,7 +2218,7 @@ LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx, LLVMTypeRef dst_type, LLVM /* TODO: We need an intrinsic to skip this conditional. */ /* Check for zero: */ return LLVMBuildSelect(ctx->builder, LLVMBuildICmp(ctx->builder, LLVMIntEQ, src0, zero, ""), - LLVMConstInt(ctx->i32, -1, 0), lsb, ""); + LLVMConstInt(ctx->i32, -1, 1), lsb, ""); } static struct ac_llvm_flow *get_current_flow(struct ac_llvm_context *ctx)