This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/50110] Endian reversal when adding extzv instruction
- From: "david.meggy at icron dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 17 Aug 2011 23:15:26 +0000
- Subject: [Bug rtl-optimization/50110] Endian reversal when adding extzv instruction
- Auto-submitted: auto-generated
- References: <bug-50110-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50110
--- Comment #4 from David Meggy <david.meggy at icron dot com> 2011-08-17 23:15:26 UTC ---
>From rtl.def
/* Reference to a signed bit-field of specified size and position.
Operand 0 is the memory unit (usually SImode or QImode) which
contains the field's first bit. Operand 1 is the width, in bits.
Operand 2 is the number of bits in the memory unit before the
first bit of this field.
If BITS_BIG_ENDIAN is defined, the first bit is the msb and
operand 2 counts from the msb of the memory unit.
Otherwise, the first bit is the lsb and operand 2 counts from
the lsb of the memory unit.
This kind of expression can not appear as an lvalue in RTL. */
DEF_RTL_EXPR(SIGN_EXTRACT, "sign_extract", "eee", RTX_BITFIELD_OPS)
/* Similar for unsigned bit-field.
But note! This kind of expression _can_ appear as an lvalue. */
DEF_RTL_EXPR(ZERO_EXTRACT, "zero_extract", "eee", RTX_BITFIELD_OPS)
It appears that this behaviour is intended. To me it seems logical that the
extract instruction is really just a "right shift", followed by an "and", where
the "and" uses a mask based on the width of the bitfield. To count from the
MSB seems counter-intuitive to me.
If my understanding is correct this code comment should appear in
http://gcc.gnu.org/onlinedocs/gccint/Standard-Names.html#Standard-Names under
the extzv and extv headings. I can fix up my define_insn to do the conversion
in our implementation.