[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, 14 Mar 2024 19:01:08 +0000 (20:01 +0100)
commitd1aef6ecd200e71d64773ec10579993048328dc8
tree97b1cd14bef59851d44dc38b488da385452cd67f
parenta2daf951fb30da7f8a34505c5453529053f4391b
[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]