Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

large generated code size in ReleaseSmall #22277

Open
dweiller opened this issue Dec 20, 2024 · 1 comment
Open

large generated code size in ReleaseSmall #22277

dweiller opened this issue Dec 20, 2024 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@dweiller
Copy link
Contributor

Zig Version

0.14.0-dev.2540+f857bf72e

Steps to Reproduce and Observed Behavior

Compile memset from compiler-rt:

zig build-lib -OReleaseSmall -fno-builtin lib/compiler_rt/memset.zig -target x86-64_linux -mcpu znver1

This target generates a 1894 byte memset function whereas -OReleaseFast generates a 209 byte function. The same issue is also present for other cpus as well here is the sample of x86_64 architectures that I checked:

CPU ReleaseSmall ReleaseFast
znver1 1894 209
znver2 1894 209
znver3 1894 209
znver4 280 209
znver5 280 209
raptorlake 1838 209
alderlake 1838 209
rocketlake 167 193
tigerlake 167 193
skylake 1894 233

The above table only has rocketlake and tigerlake producing smaller code in ReleaseSmall.

Expected Behavior

ReleaseSmall should generate less code than ReleaseFast (or at the very least be close).

I'm not sure if this is a strictly LLVM problem (and hence needs to be kicked upstream) or if Zig should be telling LLVM to do something a bit differently, but the code sizes for znver{1,2,3} and {raptor,alder,sky}lake looks worrying.

@dweiller dweiller added the bug Observed behavior contradicts documented or intended behavior label Dec 20, 2024
@dweiller
Copy link
Contributor Author

Note that these results seem very specific to certain code patterns; for example, memcpy ReleaseSmall does produce less code, despite the (Zig) code being very similar in structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

1 participant