From c740fd18ba4c7f69aed6f8ec46422fc30137039d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 17 Feb 2022 21:25:21 -0500 Subject: [PATCH] ac/llvm: replace structured by vindex != NULL in ac_build_buffer_store_common "raw" (IDXEN=0) and "structured" (IDXEN=1) do bounds checking differently. From `si_make_buffer_descriptor`: * - For VMEM and inst.IDXEN == 0 or STRIDE == 0, it's in byte units. * - For VMEM and inst.IDXEN == 1 and STRIDE != 0, it's in units of STRIDE. so there is a difference between setting vindex = i32_0 and vindex = NULL. Instead of having the `structured` flag, we can just check if vindex is NULL. Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/amd/llvm/ac_llvm_build.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c index 3d9ac3d..4fcd8f4 100644 --- a/src/amd/llvm/ac_llvm_build.c +++ b/src/amd/llvm/ac_llvm_build.c @@ -1124,18 +1124,18 @@ static unsigned get_load_cache_policy(struct ac_llvm_context *ctx, unsigned cach static void ac_build_buffer_store_common(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef data, LLVMValueRef vindex, LLVMValueRef voffset, LLVMValueRef soffset, - unsigned cache_policy, bool use_format, bool structurized) + unsigned cache_policy, bool use_format) { LLVMValueRef args[6]; int idx = 0; args[idx++] = data; args[idx++] = LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""); - if (structurized) + if (vindex) args[idx++] = vindex ? vindex : ctx->i32_0; args[idx++] = voffset ? voffset : ctx->i32_0; args[idx++] = soffset ? soffset : ctx->i32_0; args[idx++] = LLVMConstInt(ctx->i32, cache_policy, 0); - const char *indexing_kind = structurized ? "struct" : "raw"; + const char *indexing_kind = vindex ? "struct" : "raw"; char name[256], type_name[8]; ac_build_type_name_for_intr(LLVMTypeOf(data), type_name, sizeof(type_name)); @@ -1153,7 +1153,7 @@ static void ac_build_buffer_store_common(struct ac_llvm_context *ctx, LLVMValueR void ac_build_buffer_store_format(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef data, LLVMValueRef vindex, LLVMValueRef voffset, unsigned cache_policy) { - ac_build_buffer_store_common(ctx, rsrc, data, vindex, voffset, NULL, cache_policy, true, true); + ac_build_buffer_store_common(ctx, rsrc, data, vindex, voffset, NULL, cache_policy, true); } /* buffer_store_dword(,x2,x3,x4) <- the suffix is selected by the type of vdata. */ @@ -1189,7 +1189,7 @@ void ac_build_buffer_store_dword(struct ac_llvm_context *ctx, LLVMValueRef rsrc, offset = LLVMBuildAdd(ctx->builder, offset, LLVMConstInt(ctx->i32, inst_offset, 0), ""); ac_build_buffer_store_common(ctx, rsrc, ac_to_float(ctx, vdata), vindex, voffset, offset, - cache_policy, false, false); + cache_policy, false); return; } @@ -1734,8 +1734,7 @@ void ac_build_tbuffer_store_short(struct ac_llvm_context *ctx, LLVMValueRef rsrc { vdata = LLVMBuildBitCast(ctx->builder, vdata, ctx->i16, ""); - ac_build_buffer_store_common(ctx, rsrc, vdata, NULL, voffset, soffset, cache_policy, false, - false); + ac_build_buffer_store_common(ctx, rsrc, vdata, NULL, voffset, soffset, cache_policy, false); } void ac_build_tbuffer_store_byte(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef vdata, @@ -1743,8 +1742,7 @@ void ac_build_tbuffer_store_byte(struct ac_llvm_context *ctx, LLVMValueRef rsrc, { vdata = LLVMBuildBitCast(ctx->builder, vdata, ctx->i8, ""); - ac_build_buffer_store_common(ctx, rsrc, vdata, NULL, voffset, soffset, cache_policy, false, - false); + ac_build_buffer_store_common(ctx, rsrc, vdata, NULL, voffset, soffset, cache_policy, false); } /** -- 2.7.4