https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71050

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Apart from this testcase do you see any negative impact in real-world code?
That said, the positive impact on real-world code will likely be detecting
some more byte-shuffling code plus lowpart-subregs plus vector extracts.

Like some cases in PR42587 can now be handled by teaching the bswap pass
of BIT_FIELD_REF.

typedef unsigned char u8;
typedef unsigned int u32;
union __anonunion
{
  u32 value;
  u8 bytes[4];
};
u32
acpi_ut_dword_byte_swap (u32 value)
{
  union __anonunion in;
  in.value = value;
  return (((((in.bytes[0] << 8) | in.bytes[1]) << 8) | in.bytes[2]) << 8) |
in.bytes[3];
}

becomes

  <bb 2>:
  _19 = (int) value_12(D);
  _20 = _19 << 8;
  _2 = _20 & 65535;
  _15 = BIT_FIELD_REF <value_12(D), 8, 8>;
  _3 = (int) _15;
  _4 = _2 | _3;
  _5 = _4 << 8;
  _16 = BIT_FIELD_REF <value_12(D), 8, 16>;
  _6 = (int) _16;
  _7 = _5 | _6;
  _8 = _7 << 8;
  _17 = BIT_FIELD_REF <value_12(D), 8, 24>;
  _9 = (int) _17;
  _10 = _8 | _9;
  _13 = (u32) _10;
  return _13;

Reply via email to