This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/62103] Incorrect folding of bitfield in a union on big endian targets
- From: "thopre01 at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 28 Jan 2015 02:58:33 +0000
- Subject: [Bug middle-end/62103] Incorrect folding of bitfield in a union on big endian targets
- Auto-submitted: auto-generated
- References: <bug-62103-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62103
--- Comment #10 from Thomas Preud'homme <thopre01 at gcc dot gnu.org> ---
(In reply to Jiong Wang from comment #8)
> looks like this fix is too conservative. it will disable const fold for
> bit-field completely. for bitfld-6/little-endian, previously, we can
> generated
>
> main:
> mov w0, 0
> ret
>
> while after this patch, we always load from memory. any specific reason for
> this?
>
> shouldn't we fix the code to let big-endian get correct folded constant?
We only disable const folding for initialization of bitfields in a union. The
rationale was that the fix was much simpler (and could thus be backported) and
accessing a bitfield in a union that was initialized with a constant rare
enough that it wasn't worth the extra effort anyway. If this latter assumption
proves to be wrong I have the beginning of a patch that make
double_int::from_buffer and wi::from_buffer work at the bit level. It would
need to be extended to do the same to ::to_buffer.