view gcc/testsuite/gcc.dg/optimize-bswapsi-5.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
line wrap: on
line source

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

struct L { unsigned int l[2]; };
union U { double a; struct L l; } u;

void
foo (double a, struct L *p)
{
  u.a = a;
  struct L l = u.l, m;
  m.l[0] = (((l.l[1] & 0xff000000) >> 24)
	    | ((l.l[1] & 0x00ff0000) >> 8)
	    | ((l.l[1] & 0x0000ff00) << 8)
	    | ((l.l[1] & 0x000000ff) << 24));
  m.l[1] = (((l.l[0] & 0xff000000) >> 24)
	    | ((l.l[0] & 0x00ff0000) >> 8)
	    | ((l.l[0] & 0x0000ff00) << 8)
	    | ((l.l[0] & 0x000000ff) << 24));
  *p = m;
}

void
bar (double a, struct L *p)
{
  foo (a, p);
}

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