From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8AD79385141D; Wed, 12 Oct 2022 18:53:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8AD79385141D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665600837; bh=HuOLMkOSDkoLtn4BwrjuyesXcsSb0ehesdXAvk39Zm4=; h=From:To:Subject:Date:From; b=g47w1CkG9O9BcKGksN3QvYrQ0X2i0j6e13UQYJMhWM6ZlJBbEcp/e62T1oDgF6qfc JGUQNfBTSLeeEWO5OtQ/xovj4ZMPgtVoWdXm8gneKX3NWKM2e4DkKZ6G+HbSkOsJgg +QOO8MHJmYolbMgrcDx+BvhBRcdRK4+btOg/p3Us= From: "witold.baryluk+gcc at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug d/107241] New: std.bitmanip.bigEndianToNative et al not inlined Date: Wed, 12 Oct 2022 18:53:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: d X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: witold.baryluk+gcc at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ibuclaw at gdcproject dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107241 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=3Dznver2 -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=