[Bug middle-end/88739] Big-endian union bug

2019-01-07 Thread rearnsha at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88739

--- Comment #4 from Richard Earnshaw  ---
manual inspection of the output from gcc-5.4.0 suggests this version produces
correct code.

[Bug middle-end/88739] Big-endian union bug

2019-01-07 Thread wilco at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88739

--- Comment #3 from Wilco  ---
(In reply to Richard Earnshaw from comment #2)
> >   _23 = BIT_FIELD_REF <_2, 16, 0>;// WRONG: should be _2, 14, 0
> 
> _2 is declared as a 30-bit integer, so perhaps the statement is right, but
> expand needs to understand that the shift extract of the top 16 bits comes
> from a different location in big-endian.

So the question becomes what format is this in?

   _2;

Is it big-endian memory format (so value is in top 30 bits) or simply a 30-bit
value in a virtual register?

[Bug middle-end/88739] Big-endian union bug

2019-01-07 Thread rearnsha at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88739

--- Comment #2 from Richard Earnshaw  ---
>   _23 = BIT_FIELD_REF <_2, 16, 0>;// WRONG: should be _2, 14, 0

_2 is declared as a 30-bit integer, so perhaps the statement is right, but
expand needs to understand that the shift extract of the top 16 bits comes from
a different location in big-endian.

[Bug middle-end/88739] Big-endian union bug

2019-01-07 Thread wilco at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88739

Wilco  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-01-07
 CC||wilco at gcc dot gnu.org
  Component|target  |middle-end
Summary|union bug on ARM64  |Big-endian union bug
 Ever confirmed|0   |1

--- Comment #1 from Wilco  ---
Confirmed - this is a generic mid-end bug that happens in fre1 when it replaces
the bitfield store and load with the wrong bitfield extract:

Test_func (U32 ulAddr)
{
  union HEAD_REQ_DW4_UNION unData;
  unsigned int _1;
   _2;
  int _4;
  unsigned int _7;
  int _9;
  short unsigned int _10;
  int _11;
  short unsigned int _23;

   :
  _1 = ulAddr_12(D) >> 2;
  _2 = () _1;
  unData.strMemHead.b30AddrL = _2;
  unData.strMemHead.b2AddrType = 0;
  _4 = (int) _2;
  printf ("unData.strMemHead.b30AddrL=0x%x\r\n", _4);
  printf ("unData.strMemHead.b2AddrType=0x%x\r\n", 0);
  _7 = unData.aulValue[3];
  printf ("unData.aulValue[3]=0x%x\r\n", _7);
  _23 = BIT_FIELD_REF <_2, 16, 0>;// WRONG: should be _2, 14, 0
  _9 = (int) _23;
  printf ("unData.ausValue[6]=0x%x\r\n", _9);
  _10 = unData.ausValue[7];
  _11 = (int) _10;
  printf ("unData.ausValue[7]=0x%x\r\n", _11);
  unData ={v} {CLOBBER};
  return 0;

}