This is the mail archive of the
mailing list for the GCC project.
Re: How to efficiently unpack 8 bytes from a 64-bit integer?
- From: Phil Ruffwind <rf at rufflewind dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: GCC Development <gcc at gcc dot gnu dot org>
- Date: Fri, 19 Feb 2016 04:44:18 -0500
- Subject: Re: How to efficiently unpack 8 bytes from a 64-bit integer?
- Authentication-results: sourceware.org; auth=none
- References: <CADb8sTOdGE7UJtCHQA4q8y94av70=U_wOd2vv1ibwyQs2xtbmw at mail dot gmail dot com> <CAFiYyc1DqAqUcD8mZLhbdbSonOakXDPqBXSGNEw2_8GneHkUeQ at mail dot gmail dot com>
I tried to look for a workaround for this. It seemed that using a
union instead of memcpy was enough to convince GCC to optimize into a
struct alpha unpack(uint64_t x)
struct alpha r;
u.i = x;
But that trick turned out to be short-lived. If I wrap the wrapper
with another function:
struct alpha wrapperwrapper(uint64_t y)
I get the same 37-line assembly generated for this function. What's
even more strange is that if I just define two identical wrappers in
the same translation unit:
struct alpha wrapper(uint64_t y)
struct alpha wrapper2(uint64_t y)
One of them gets optimized perfectly, while the other fails, even
though the bodies of the two functions are completely identical!