https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107241
Bug ID: 107241 Summary: std.bitmanip.bigEndianToNative et al not inlined Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: d Assignee: ibuclaw at gdcproject dot org Reporter: witold.baryluk+gcc at gmail dot com Target Milestone: --- gdc fails to inline number of small functions that should fully inline and end in single instruction. on amd64 / x86, for example std.bitmanip.bigEndianToNative causes a chain of calls / jumps, even with @attribute("flatten") import std.bitmanip; import gcc.attributes; @attribute("flatten") size_t f(char[] b) { return std.bitmanip.bigEndianToNative!(size_t, 8)(cast(ubyte[8])(b[2..10])); } gcc -O3 -march=znver2 -frelease pure nothrow @nogc @safe ulong std.bitmanip.swapEndian!(ulong).swapEndian(const(ulong)): mov rax, rdi bswap rax ret pure nothrow @nogc @safe ulong std.bitmanip.endianToNativeImpl!(true, ulong, 8uL).endianToNativeImpl(ubyte[8]): jmp pure nothrow @nogc @safe ulong std.bitmanip.swapEndian!(ulong).swapEndian(const(ulong)) pure nothrow @nogc @safe ulong std.bitmanip.bigEndianToNative!(ulong, 8uL).bigEndianToNative(ubyte[8]): jmp pure nothrow @nogc @safe ulong std.bitmanip.endianToNativeImpl!(true, ulong, 8uL).endianToNativeImpl(ubyte[8]) ulong example.f(char[]): mov rdi, QWORD PTR [rsi+2] jmp pure nothrow @nogc @safe ulong std.bitmanip.bigEndianToNative!(ulong, 8uL).bigEndianToNative(ubyte[8]) No issues with LDC. ulong example.f(char[]): mov rax, qword ptr [rsi + 2] bswap rax ret godbolt: https://godbolt.org/z/Pj3f7oGso