public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/107241] New: std.bitmanip.bigEndianToNative et al not inlined
@ 2022-10-12 18:53 witold.baryluk+gcc at gmail dot com
2022-10-12 18:56 ` [Bug d/107241] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: witold.baryluk+gcc at gmail dot com @ 2022-10-12 18:53 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/107241] std.bitmanip.bigEndianToNative et al not inlined
2022-10-12 18:53 [Bug d/107241] New: std.bitmanip.bigEndianToNative et al not inlined witold.baryluk+gcc at gmail dot com
@ 2022-10-12 18:56 ` pinskia at gcc dot gnu.org
2022-10-12 18:57 ` pinskia at gcc dot gnu.org
2022-10-13 5:45 ` ibuclaw at gdcproject dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-12 18:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107241
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm:
__attribute__((weak))
ulong swapEndian (const ulong val)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/107241] std.bitmanip.bigEndianToNative et al not inlined
2022-10-12 18:53 [Bug d/107241] New: std.bitmanip.bigEndianToNative et al not inlined witold.baryluk+gcc at gmail dot com
2022-10-12 18:56 ` [Bug d/107241] " pinskia at gcc dot gnu.org
@ 2022-10-12 18:57 ` pinskia at gcc dot gnu.org
2022-10-13 5:45 ` ibuclaw at gdcproject dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-12 18:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107241
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> Hmm:
> __attribute__((weak))
> ulong swapEndian (const ulong val)
Note this is definitely a front-end issue .
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/107241] std.bitmanip.bigEndianToNative et al not inlined
2022-10-12 18:53 [Bug d/107241] New: std.bitmanip.bigEndianToNative et al not inlined witold.baryluk+gcc at gmail dot com
2022-10-12 18:56 ` [Bug d/107241] " pinskia at gcc dot gnu.org
2022-10-12 18:57 ` pinskia at gcc dot gnu.org
@ 2022-10-13 5:45 ` ibuclaw at gdcproject dot org
2 siblings, 0 replies; 4+ messages in thread
From: ibuclaw at gdcproject dot org @ 2022-10-13 5:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107241
Iain Buclaw <ibuclaw at gdcproject dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #3 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Looks like pr102765 to me.
*** This bug has been marked as a duplicate of bug 102765 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-10-13 5:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-12 18:53 [Bug d/107241] New: std.bitmanip.bigEndianToNative et al not inlined witold.baryluk+gcc at gmail dot com
2022-10-12 18:56 ` [Bug d/107241] " pinskia at gcc dot gnu.org
2022-10-12 18:57 ` pinskia at gcc dot gnu.org
2022-10-13 5:45 ` ibuclaw at gdcproject dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).