This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Strangeness (maybe a bug?) in expmed.c: extract_bit_field_1()
Jeff Kenton <jkenton@tilera.com> writes:
> In expmed.c: extract_bit_field_1() I see the following:
>
> /* On big-endian machines, we count bits from the most significant.
> If the bit field insn does not, we must invert. */
> if (BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN)
> xbitpos = unit - bitsize - xbitpos;
>
> This produces a negative value for xbitpos for BIG_ENDIAN code,
> despite the fact that xbitpos is declared unsigned. The code in
> alpha/alpha.md that it calls promptly converts the bit offset back to
> its original value, and I have to do the same for my own BIG_ENDIAN
> port.
>
> This smells like a bug, although I suspect changing it would break
> existing ports.
Please do not start a new thread by replying to an existing message.
Please send a new message instead. Starting a new thread via a reply
breaks threaded mail readers. Thanks.
That statement does look a bit suspicious. I'm not sure what bitsize is
doing in there. As you say, before fixing it it would be necessary to
look at a port which has an insv instruction and for which
BITS_BIG_ENDIAN != BYTES_BIG_ENDIAN. ARM in big-endian mode would be an
example.
Ian