Files
metal2vulkan/crates
Anees Iqbal aaeb7fa475 SEMANTICS 2126, RUNTIME 2396: Static initializers evaluate integer vectors lane by lane
A static initializer's integer arithmetic, comparisons and casts of vectors were left
unevaluated (the folder's integer folds take scalars), so a module whose initializer builds a
vector global from its function constants refused at specialization: Unsupported
StaticInitializer. MPSCore's stitchable functions are such modules (their initializer stores
<4 x i32> and <4 x i8> globals built from two ushort constants by scalar bit tests inserted
into undef vectors and a zext of a <4 x i1>), so every kernel linking them, 257 of the census's
265 refused MPS rows once linked, refused there.

Folder::lanewise applies a scalar integer fold to each lane of constant vectors of the result's
lane count; the static-initializer interpreter takes it for integer binops, icmp and integer
casts. A vector with an undef or otherwise unknown lane is still not evaluated (the module is
refused as before). SCCP's folds are unchanged: only static initializers evaluate vectors.

Test: canon::tests::static_vectors builds that initializer's shape (lanes inserted into undef,
scalar compares into <4 x i1> then zext, trunc/lshr/and of a scalar, and splat/lshr/and/icmp/
zext/trunc on vectors throughout) and checks the kernel's stores fold to the lanes' values;
a vector with an undef lane still refuses.

Verified in the lane: canon::tests::static_vectors 2/2 and a negative control without the fold
(it refuses); metal2vulkan-air clippy clean and its suite 570 passed (m3-max-34114); a release
linked census of the 265 refused MPS rows with this commit (m3-max-34128): 234 translate and pass
spirv-val, slowest 0.39 s, largest 199 MiB.
2026-11-15 16:44:14 -08:00
..