#Spurious Copies for inline else?
1 messages · Page 1 of 1 (latest)
Most attempts Ive made at using inline else with switch have produced suboptimal code compared to the code I can write by hand. This is the latest example, though it really made me wonder what was going on
Both examples are compiled with Zig 0.15.2, with -DReleaseFast -fllvm
What am I doing wrong?
Here are the full assembly listings for both, respectfully
The inline if version produces over 100 more instructions than the manual version
youre compiling in debug mode, -D defines a C macro on the CLI
you want -O instead (for zig build-[exe|lib|obj]), which godbot uses
or -Doptimize=[mode] when using zig build
the latter uses -D as it is defining an option for the build script
whereas the former is a direct argument to the compiler.
Well then, I suppose I'm not the sharpest spoon in the drawer.
Thank you for the easy fix 