-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
CBE copies entire array to new variable before accessing it #21724
Copy link
Copy link
Open
Labels
backend-cThe C backend (CBE) outputs C source code.The C backend (CBE) outputs C source code.enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.optimization
Milestone
Metadata
Metadata
Assignees
Labels
backend-cThe C backend (CBE) outputs C source code.The C backend (CBE) outputs C source code.enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.optimization
Zig Version
0.13.0
Steps to Reproduce and Observed Behavior
Compile the following code with
zig build-exe -lc -ofmt=c /tmp/magic.zig -O ReleaseFastand check out the generated C file:This code generates
Both GCC 14.2 and Clang emit the
memcpyand are not able to optimizet8away.Expected Behavior
The array
t8is unnecessarily created copied before accessing it.I don't expect Zig to emit the
memcpy(t8, (const char *)&t0, sizeof(uint8_t[2147483648]));