view gcc/testsuite/gcc.dg/optimize-bswapsi-4.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* { dg-do compile } */
/* { dg-require-effective-target bswap } */
/* { dg-options "-O2 -fdump-tree-bswap" } */
/* { dg-additional-options "-march=z900" { target s390-*-* } } */

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;
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
  return ((in.bytes[0] << 24) | (in.bytes[1] << 16)
	  | (in.bytes[2] << 8) | in.bytes[3]);
#else
  return ((in.bytes[3] << 24) | (in.bytes[2] << 16)
	  | (in.bytes[1] << 8) | in.bytes[0]);
#endif
}

/* { dg-final { scan-tree-dump "32 bit bswap implementation found at" "bswap" } } */