summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/powerpc/bswap-brw.c
blob: b3f923eea84816f6e29a35b1122d08fd8b7376f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* { dg-require-effective-target power10_ok } */
/* { dg-options "-O2 -mdejagnu-cpu=power10" } */

/* This tests whether GCC generates the ISA 3.1 BRW byte swap instruction for
   GPR data, but generates XXBRW for data in a vector register.  */

unsigned int
bswap_int (unsigned int a)
{
  return __builtin_bswap32 (a); /* { dg-final { scan-assembler {\mbrw\M} } } */
}

double
bswap_int_dbl (unsigned int a)
{
  unsigned int b = a;
  /* Force the value to be loaded into a vector register.  */
  __asm__ (" # %x0" : "+wa" (b));

  /* { dg-final { scan-assembler {\mxxbrw\M} } } */
  return (double) __builtin_bswap32 (b);
}