[PATCH 73/79] [Backport to 15] Fix SPIR-V global to function replacement for differin...
authorMaksim Shelegov <maksim.shelegov@intel.com>
Wed, 29 Nov 2023 11:58:58 +0000 (03:58 -0800)
committerAndreas Beckmann <anbe@debian.org>
Thu, 8 Feb 2024 21:48:18 +0000 (22:48 +0100)
commitceb892b39d7a6801cb509951e03870138d774827
tree1a09e3f9f65aa400a6cb4ffe5a7dfe8799501f69
parenta280524a6e281b002def567a4c80d10aec80525e
[PATCH 73/79] [Backport to 15] Fix SPIR-V global to function replacement for differing load types (#2160) (#2243)

In some cases, we will see IR with the following

@__spirv_BuiltInGlobalInvocationId = external dso_local local_unnamed_addr addrspace(1) constant <3 x i64>, align 32

...

%0 = load <6 x i32>, ptr addrspace(1) @__spirv_BuiltInGlobalInvocationId, align 32
%1 = extractelement <6 x i32> %0, i64 0
Note the global type and load type are different. Change the handling of vector loads from vector globals to reconstruct the global vector type and then bitcast to the load type.

Thanks to @jcranmer-intel for helping me find the simplest solution.

Co-authored-by: Nick Sarnie <sarnex@users.noreply.github.com>
Gbp-Pq: Name 0073-Backport-to-15-Fix-SPIR-V-global-to-function-replace.patch
lib/SPIRV/SPIRVUtil.cpp
test/transcoding/builtin_vars_different_type.ll [new file with mode: 0644]