public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jari.helaakoski at qt dot io" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113478] New: -Os does not inline single instruction function Date: Thu, 18 Jan 2024 12:56:28 +0000 [thread overview] Message-ID: <bug-113478-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113478 Bug ID: 113478 Summary: -Os does not inline single instruction function Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jari.helaakoski at qt dot io Target Milestone: --- GCC -Os option does not inline single instruction std::atomic function when accessed via template class. Inlining works ok with -O2. Inlining is also working if std::atomic is used directly. Test case and compilation result found from godbolt: https://godbolt.org/z/nh758aT3K Problem reproduces all GCC versions with x86 and aarch64 target and with and without specific -march and -mtune options. And here's test case pasted in case of godbolt is not accessable: template <typename T> class D { public: #if 1 inline T test() { return i.load(std::memory_order_relaxed); } #else __attribute__((always_inline)) T test() { return i.load(std::memory_order_relaxed); } #endif std::atomic<T> i {0}; }; D<char> a1; D<long> a2; D<int> a3; D<short> a4; D<long long> a5; D<wchar_t> a6; extern void mod(); int main() { int ret = 0; mod(); ret |= a1.test(); ret |= a1.test(); ret |= a1.test(); ret |= a1.test(); ret |= a1.test(); ret |= a1.test(); ret |= a1.test(); ret |= a1.test(); ret |= a1.test(); ret |= a1.test(); ret |= a2.test(); ret |= a3.test(); ret |= a4.test(); ret |= a5.test(); ret |= a6.test(); return ret; } Function that should be inlined D<char>::test(): ldrb w0, [x0] ret
next reply other threads:[~2024-01-18 12:56 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-18 12:56 jari.helaakoski at qt dot io [this message] 2024-01-18 13:12 ` [Bug ipa/113478] " rguenth at gcc dot gnu.org 2024-01-19 10:51 ` hubicka at ucw dot cz 2024-01-19 11:09 ` rguenth at gcc dot gnu.org 2024-01-19 16:43 ` hubicka at ucw dot cz
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-113478-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).