November 01, 2021 [Issue 22466] New: Small array initialization and assignment shouldn't defer to memset | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22466 Issue ID: 22466 Summary: Small array initialization and assignment shouldn't defer to memset Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: stanislav.blinov@gmail.com // 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). -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply