aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/aarch64/adds3.c
blob: 18efd1c21544d9c9a44bdb7e3f44d3d77d4c49b4 (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
/* { dg-do run } */
/* { dg-options "-O2 --save-temps -fno-inline" } */

extern void abort (void);
typedef long long s64;

int
adds_ext (s64 a, int b, int c)
{
 s64 d = a + b;

  if (d == 0)
    return a + c;
  else
    return b + d + c;
}

int
adds_shift_ext (s64 a, int b, int c)
{
 s64 d = (a + ((s64)b << 3));

  if (d == 0)
    return a + c;
  else
    return b + d + c;
}

int main ()
{
  int x;
  s64 y;

  x = adds_ext (0x13000002ll, 41, 15);
  if (x != 318767203)
    abort ();

  x = adds_ext (0x50505050ll, 29, 4);
  if (x != 1347440782)
    abort ();

  x = adds_ext (0x12121212121ll, 2, 14);
  if (x != 555819315)
    abort ();

  x = adds_shift_ext (0x123456789ll, 4, 12);
  if (x != 591751097)
    abort ();

  x = adds_shift_ext (0x02020202ll, 9, 8);
  if (x != 33686107)
    abort ();

  x = adds_shift_ext (0x987987987987ll, 23, 41);
  if (x != -2020050305)
    abort ();

  return 0;
}

/* { dg-final { scan-assembler-times "adds\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+, sxtw" 2 } } */