summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/multiword-1.c
blob: c08161791d6884b86ff7df14550692957416d8fb (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
/* { dg-do run } */
/* { dg-options "-O3" } */
/* { dg-require-effective-target ilp32 } */

typedef unsigned int u32;
typedef unsigned long long u64;

u64 __attribute__((noinline))
foo (u32 high, u32 low)
{
  return ((u64)high << 32) | low;
}

u32 __attribute__((noinline))
right (u64 t)
{
  return (u32)(t >> 32);
}

u64 __attribute__((noinline))
left (u32 t)
{
  return (u64)t << 32;
}

u32 __attribute__((noinline))
right2 (u64 t)
{
  return (u32)(t >> 40);
}

u64 __attribute__((noinline))
left2 (u32 t)
{
  return (u64)t << 40;
}

u64 __attribute__((noinline))
zeroextend (u32 t)
{
  return (u64)t;
}

extern void abort ();

int
main ()
{
  if (foo (13000, 12000) != 55834574860000ULL)
    abort ();

  if (right (55834574860000ULL) != 13000)
    abort ();

  if (left (13000) != 55834574848000ULL)
    abort ();

  if (right2 (55834574860000ULL) != 50)
    abort ();

  if (left2 (13000) != 14293651161088000ULL)
    abort ();

  if (zeroextend (13000) != 13000ULL)
    abort ();

  return 0;
}