https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86723
Bug ID: 86723
Summary: G++ not optimizing with bswap when inlining with
constexpr
Product: gcc
Version: 8.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kiwixz at outlook dot com
Target Milestone: ---
Created attachment 44461
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44461&action=edit
souce.cpp
Compiling attachment with `-std=c++17 -O3`, I expect g++ to optimize the
swap_unsigned function to a bswap instruction.
It does so, like for equivalent functions (not included here) for 32/16 bits
swap.
Unfortunately, if I add constexpr to the 64 bits swap_unsigned function, it
gets inlined and no longer use bswap.
Interestingely, using __attribute__((noinline)) will force g++ to use bswap.