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
In the link above you will see these 4 functions. Each pair of function should do the exact same thing. First function contains the manually inlined code that I copied and pasted just to make sure it's really inlined and in the other I called the function.
The problem is that the assembly of the versions where the function is used are just crazy, and do way more stuff that it really should.
-Doptimize=ReleaseFast is an option you pass to zig build when a build script is using std.Built.standardOptimizeOption. When directly building a binary with build-exe/build-obj/build-lib, which is what Godbolt does, you need to use -OReleaseFast instead. The option you're passing isn't doing anything helpful (it's just defining a C macro!).
When you pass the correct optimization option, the codegen is identical for the two functions: https://godbolt.org/z/cKWTdTYWf
mlugg
added
question
No questions on the issue tracker, please.
and removed
bug
Observed behavior contradicts documented or intended behavior
labels
Mar 13, 2024
Zig Version
0.12.0-dev.3282+da5b16f9e
Steps to Reproduce and Observed Behavior
Please give a the code in action here: https://godbolt.org/z/6T1edKa94
In the link above you will see these 4 functions. Each pair of function should do the exact same thing. First function contains the manually inlined code that I copied and pasted just to make sure it's really inlined and in the other I called the function.
The problem is that the assembly of the versions where the function is used are just crazy, and do way more stuff that it really should.
I'm using
-Doptimize=ReleaseFast
Expected Behavior
Both assemblies of each pair should be identical
The text was updated successfully, but these errors were encountered: