You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I stumbled across this issue in the rust compiler and started playing with it in zig. With some help of @lithdew, it appears that similarly to rust, zig does not vectorize the function call. We tried with std.meta.eql, but the current zig implementation seems like a much more simple reproduction case
Unfortunately I don't know enough about compilers to debug further. If folks have an idea for how to dig into this, happy to learn and give it a shot with some advice.
The issue appears to come down to how passing by reference and passing by pointer differs in C++. Zig automatically assumes passing by pointer for function arguments, and therefore can't vectorize as well in comparison to passing by reference like in C++.
Here's the difference in assembly between passing by reference and passing by pointer in C++: https://godbolt.org/z/WYc1W489r
The issue appears to come down to how passing by reference and passing by pointer differs in C++.
Not really. The problem is that the emitted IR is too convoluted and is failing to trigger the mergeicmps pass, Clang's IR manages to get all the comparisons to be folded into a single memcmp that's then expanded into vectorized ops.
I stumbled across this issue in the rust compiler and started playing with it in zig. With some help of @lithdew, it appears that similarly to rust, zig does not vectorize the function call. We tried with
std.meta.eql
, but the current zig implementation seems like a much more simple reproduction caseZig Godbolt
C++ Godbolt
Unfortunately I don't know enough about compilers to debug further. If folks have an idea for how to dig into this, happy to learn and give it a shot with some advice.
It looks like there may be some difference between C++ pointers and references
https://godbolt.org/z/qaGfYf95j
The text was updated successfully, but these errors were encountered: