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.

Reply via email to