summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/aarch64/bics_4.c
blob: d01b5f26dbcad93c50eeed70c2e5a58463446e5b (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
83
84
85
86
/* { dg-do run } */
/* { dg-options "-O2 --save-temps -fno-inline" } */

extern void abort (void);

int
bics_si_test1 (int a, int b, int c)
{
  if ((a & b) == a)
    return a;
  else
    return c;
}

int
bics_si_test2 (int a, int b, int c)
{
  if ((a & b) == b)
    return b;
  else
    return c;
}

typedef long long s64;

s64
bics_di_test1 (s64 a, s64 b, s64 c)
{
  if ((a & b) == a)
    return a;
  else
    return c;
}

s64
bics_di_test2 (s64 a, s64 b, s64 c)
{
  if ((a & b) == b)
    return b;
  else
    return c;
}

int
main ()
{
  int x;
  s64 y;

  x = bics_si_test1 (0xf00d, 0xf11f, 0);
  if (x != 0xf00d)
    abort ();

  x = bics_si_test1 (0xf11f, 0xf00d, 0);
  if (x != 0)
    abort ();

  x = bics_si_test2 (0xf00d, 0xf11f, 0);
  if (x != 0)
    abort ();

  x = bics_si_test2 (0xf11f, 0xf00d, 0);
  if (x != 0xf00d)
    abort ();

  y = bics_di_test1 (0x10001000f00dll, 0x12341000f00dll, 0ll);
  if (y != 0x10001000f00dll)
    abort ();

  y = bics_di_test1 (0x12341000f00dll, 0x10001000f00dll, 0ll);
  if (y != 0)
    abort ();

  y = bics_di_test2 (0x10001000f00dll, 0x12341000f00dll, 0ll);
  if (y != 0)
    abort ();

  y = bics_di_test2 (0x12341000f00dll, 0x10001000f00dll, 0ll);
  if (y != 0x10001000f00dll)
    abort ();

  return 0;
}

/* { dg-final { scan-assembler-times "bics\twzr, w\[0-9\]+, w\[0-9\]+" 2 } } */
/* { dg-final { scan-assembler-times "bics\txzr, x\[0-9\]+, x\[0-9\]+" 2 } } */