[Mesa-dev] [PATCH 12/24] radeonsi: set readnone on reads from read-only memory
Marek Olšák
maraeo at gmail.com
Sat Mar 11 01:53:07 UTC 2017
On Fri, Mar 10, 2017 at 11:03 PM, Constantine Kharlamov
<Hi-Angel at yandex.ru> wrote:
>
> On 26.02.2017 02:58, Marek Olšák wrote:
>> From: Marek Olšák <marek.olsak at amd.com>
>>
>> ---
>> src/amd/common/ac_llvm_build.c | 11 +++++++++--
>> src/amd/common/ac_llvm_build.h | 3 ++-
>> src/gallium/drivers/radeonsi/si_shader.c | 20 ++++++++++----------
>> 3 files changed, 21 insertions(+), 13 deletions(-)
>>
>> diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
>> index 42965b6..f0ab9cb 100644
>> --- a/src/amd/common/ac_llvm_build.c
>> +++ b/src/amd/common/ac_llvm_build.c
>> @@ -612,21 +612,22 @@ ac_build_tbuffer_store_dwords(struct ac_llvm_context *ctx,
>>
>> LLVMValueRef
>> ac_build_buffer_load(struct ac_llvm_context *ctx,
>> LLVMValueRef rsrc,
>> int num_channels,
>> LLVMValueRef vindex,
>> LLVMValueRef voffset,
>> LLVMValueRef soffset,
>> unsigned inst_offset,
>> unsigned glc,
>> - unsigned slc)
>> + unsigned slc,
>> + bool readonly_memory)
>> {
>> unsigned func = CLAMP(num_channels, 1, 3) - 1;
>>
>> if (HAVE_LLVM >= 0x309) {
>> LLVMValueRef args[] = {
>> LLVMBuildBitCast(ctx->builder, rsrc, ctx->v4i32, ""),
>> vindex ? vindex : LLVMConstInt(ctx->i32, 0, 0),
>> LLVMConstInt(ctx->i32, inst_offset, 0),
>> LLVMConstInt(ctx->i1, glc, 0),
>> LLVMConstInt(ctx->i1, slc, 0)
>> @@ -644,21 +645,27 @@ ac_build_buffer_load(struct ac_llvm_context *ctx,
>>
>> if (soffset) {
>> args[2] = LLVMBuildAdd(ctx->builder, args[2], soffset,
>> "");
>> }
>>
>> snprintf(name, sizeof(name), "llvm.amdgcn.buffer.load.%s",
>> type_names[func]);
>>
>> return ac_emit_llvm_intrinsic(ctx, name, types[func], args,
>> - ARRAY_SIZE(args), AC_FUNC_ATTR_READONLY);
>> + ARRAY_SIZE(args),
>> + /* READNONE means writes can't
>> + * affect it, while READONLY means
>> + * that writes can affect it. */
>> + readonly_memory ?
>> + AC_FUNC_ATTR_READNONE :
>> + AC_FUNC_ATTR_READONLY);
>
> You probably swapped the arguments, i.e. when "readonly_memory == true",
> you're passing AC_FUNC_ATTR_READNONE instead of AC_FUNC_ATTR_READONLY.
I'm sure I didn't. The flag is readonly_*memory*, but the attribute
describes the intrinsic, not the memory. By telling LLVM that the
intrinsic doesn't read memory, LLVM can assume that memory writes
won't affect it. That's exactly what we want for read-only memory.
Marek
More information about the mesa-dev
mailing list