Description
llvm fails to add static offset address to memory load instructions in some cases.
Here is godbold link that demonstrates the issue:
https://godbolt.org/z/c6oPfehfo
The function get_YY
should load value from memory address having static offset of 20, like all other functions in example.
Instead, it adds 20 to existing memory address by arithmetic operator.
All other load instructions that have offset less than 20 are using static offset as seen in godbold output.
The llvm code itself is correct:
define hidden float @_ZN7example6get_YY17h71095c69e6bab6acE(%"Vec4<Vec4<f32>>"* noalias nocapture noundef readonly align 4 dereferenceable(64) %v) unnamed_addr #0 !dbg !23 {
%0 = getelementptr inbounds %"Vec4<Vec4<f32>>", %"Vec4<Vec4<f32>>"* %v, i32 0, i32 1, i32 1, !dbg !24
%1 = load float, float* %0, align 4, !dbg !24
ret float %1, !dbg !25
}
Link to llvm output: https://godbolt.org/z/z4ehToarG
When same struct is refactored to have five component, it works on offset 20, but does not work on offset 24. So it seems problem is always from the second component on second vector.
https://godbolt.org/z/Meq858KWq
The issue occurs only when targeting to WASM, the X86 instructions are fine https://godbolt.org/z/sx67bW7dv