ac/llvm: Fix alignment of shared load intrinsics.

After some research, I found out that the alignment needs to be set
on the return value of the load, rather than on the pointer.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Tested-by: Michel Dänzer <mdaenzer@redhat.com>
Fixes: 14ad82b4e9 "ac/llvm: Emit more efficient code for load_shared."
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9688>
This commit is contained in:
Timur Kristóf 2021-03-18 16:53:26 +01:00 committed by Marge Bot
parent 3413c48375
commit f5717f9f54

View file

@ -2967,9 +2967,9 @@ static LLVMValueRef visit_load_shared(struct ac_nir_context *ctx, const nir_intr
LLVMTypeRef result_type = get_def_type(ctx, &instr->dest.ssa);
int addr_space = LLVMGetPointerAddressSpace(LLVMTypeOf(ptr));
LLVMValueRef derived_ptr = LLVMBuildBitCast(ctx->ac.builder, ptr, LLVMPointerType(result_type, addr_space), "");
LLVMSetAlignment(derived_ptr, alignment);
LLVMValueRef ret = LLVMBuildLoad(ctx->ac.builder, derived_ptr, "");
LLVMSetAlignment(ret, alignment);
return LLVMBuildBitCast(ctx->ac.builder, ret, get_def_type(ctx, &instr->dest.ssa), "");
}