Comment #0 by stanislav.blinov — 2021-11-01T18:31:15Z
// dmd -betterC
extern(C) void main(int argc, char** argv)
{
int[4] arr = 1;
}
Results in:
bugs/smallarray.d:(.text.main[main]+0x1f): undefined reference to `_memset32'
That is a meager four 32-bit stores. It's an unnecessary pessimization to defer this to a *function call*, source of which may or may not be visible to the compiler, implementation of which would have branches. Compiler should just emit the four stores here.
This is not just for ints, other built-in types should also benefit. Upper bound for avoiding the function call may be up to 512 bits worth of stores (to correspond to current SIMD widths).
Comment #1 by bugzilla — 2023-01-15T07:59:03Z
With the current master, Look Ma, no memset32!!
_D4testQfFZv:
0000: 55 push RBP
0001: 48 8B EC mov RBP,RSP
0004: 48 83 EC 10 sub RSP,010h
0008: 48 B8 01 00 00 00 01 00 00 00 mov RAX,0100000001h
0012: 48 89 45 F0 mov -010h[RBP],RAX
0016: 48 89 45 F8 mov -8[RBP],RAX
001a: C9 leave
001b: C3 ret