Open Validark opened 7 months ago
@mlugg Is this likely to be a problem that should be solved in the Zig compiler itself or in LLVM?
Ideally LLVM would just be improved to optimize this code correctly - however, if that doesn't happen, we may be able to make the compiler emit different LLVM IR which optimizes better.
Zig Version
0.12.0-dev.2284+9b714e019
Steps to Reproduce and Observed Behavior
See godbolt
This code results in horrible assembly:
Expected Behavior
Should be compiled to the same thing as:
The latter of which compiles like so on the latest x86_64: