aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/sh/pr53568-1.c
blob: e274170fe1f303bc6656ab4282fb8fdc8cf74159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* Check that the bswap32 pattern is generated as swap.b and swap.w
   instructions.  */
/* { dg-do compile }  */
/* { dg-options "-O2" } */
/* { dg-skip-if "" { "sh*-*-*" } { "-m5*"} { "" } }  */
/* { dg-final { scan-assembler-times "swap.w" 7 } } */
/* { dg-final { scan-assembler-times "swap.b" 16 } } */
/* { dg-final { scan-assembler-times "extu.w" 2 } } */
/* { dg-final { scan-assembler-times "mov" 1 } } */
/* { dg-final { scan-assembler-not "{shll8|shlr8|shld|shad}" } } */

int
test_func_00 (int a)
{
  /* 1x swap.w
     2x swap.b  */
  return __builtin_bswap32 (a);
}

unsigned int
test_func_01 (unsigned int a)
{
  /* 1x swap.w
     2x swap.b  */
  return __builtin_bswap32 (a);
}

int
test_func_02 (int a)
{
  /* 1x swap.w
     2x swap.b  */
  return (((a >> 0) & 0xFF) << 24)
	 | (((a >> 8) & 0xFF) << 16)
	 | (((a >> 16) & 0xFF) << 8)
	 | (((a >> 24) & 0xFF) << 0);
}

unsigned int
test_func_03 (unsigned int a)
{
  /* 1x swap.w
     2x swap.b  */
  return (((a >> 0) & 0xFF) << 24)
	 | (((a >> 8) & 0xFF) << 16)
	 | (((a >> 16) & 0xFF) << 8)
	 | (((a >> 24) & 0xFF) << 0);
}

int
test_func_04 (int a)
{
  /* 1x swap.b
     1x extu.w  */
  return __builtin_bswap32 (a) >> 16;
}

unsigned short
test_func_05 (unsigned short a)
{
  /* 1x swap.b
     1x extu.w  */
  return __builtin_bswap32 (a) >> 16;
}

long long
test_func_06 (long long a)
{
  /* 2x swap.w
     4x swap.b  */
  return __builtin_bswap64 (a);
}

long long
test_func_07 (long long a)
{
  /* 1x swap.w
     2x swap.b
     1x mov #0,Rn  */
  return __builtin_bswap64 (a) >> 32;
}