[AArch64][testsuite] Adjust some arith+compare tests for potentially more aggressive...
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / ands_1.c
blob005924625ccdd9950ff1501bfb17152dfc36ff20
1 /* { dg-do run } */
2 /* { dg-options "-O2 --save-temps -fno-inline" } */
4 extern void abort (void);
6 int
7 ands_si_test1 (int a, int b, int c)
9 int d = a & b;
11 /* { dg-final { scan-assembler-times "ands\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+" 2 } } */
12 if (d == 0)
13 return a + c;
14 else
15 return d;
18 int
19 ands_si_test2 (int a, int b, int c)
21 int d = a & 0xff;
23 /* { dg-final { scan-assembler "ands\tw\[0-9\]+, w\[0-9\]+, 255" } } */
24 if (d == 0)
25 return a + c;
26 else
27 return d;
30 int
31 ands_si_test3 (int a, int b, int c)
33 int d = a & (b << 3);
35 /* { dg-final { scan-assembler "ands\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+, lsl 3" } } */
36 if (d == 0)
37 return a + c;
38 else
39 return d;
42 typedef long long s64;
44 s64
45 ands_di_test1 (s64 a, s64 b, s64 c)
47 s64 d = a & b;
49 /* { dg-final { scan-assembler-times "ands\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" 2 } } */
50 if (d == 0)
51 return a + c;
52 else
53 return d;
56 s64
57 ands_di_test2 (s64 a, s64 b, s64 c)
59 s64 d = a & 0xff;
61 /* { dg-final { scan-assembler "ands\tx\[0-9\]+, x\[0-9\]+, 255" } } */
62 if (d == 0)
63 return a + c;
64 else
65 return d;
68 s64
69 ands_di_test3 (s64 a, s64 b, s64 c)
71 s64 d = a & (b << 3);
73 /* { dg-final { scan-assembler "ands\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+, lsl 3" } } */
74 if (d == 0)
75 return a + c;
76 else
77 return d;
80 int
81 main ()
83 int x;
84 s64 y;
86 x = ands_si_test1 (29, 4, 5);
87 if (x != (29 & 4))
88 abort ();
90 x = ands_si_test1 (5, 2, 20);
91 if (x != 25)
92 abort ();
94 x = ands_si_test2 (29, 4, 5);
95 if (x != (29 & 0xff))
96 abort ();
98 x = ands_si_test2 (1024, 2, 20);
99 if (x != 1044)
100 abort ();
102 x = ands_si_test3 (35, 4, 5);
103 if (x != (35 & (4 << 3)))
104 abort ();
106 x = ands_si_test3 (5, 2, 20);
107 if (x != 25)
108 abort ();
110 y = ands_di_test1 (0x130000029ll,
111 0x320000004ll,
112 0x505050505ll);
114 if (y != ((0x130000029ll & 0x320000004ll)))
115 abort ();
117 y = ands_di_test1 (0x5000500050005ll,
118 0x2111211121112ll,
119 0x0000000002020ll);
120 if (y != 0x5000500052025ll)
121 abort ();
123 y = ands_di_test2 (0x130000029ll,
124 0x320000004ll,
125 0x505050505ll);
126 if (y != ((0x130000029ll & 0xff)))
127 abort ();
129 y = ands_di_test2 (0x130002900ll,
130 0x320000004ll,
131 0x505050505ll);
132 if (y != (0x130002900ll + 0x505050505ll))
133 abort ();
135 y = ands_di_test3 (0x130000029ll,
136 0x064000008ll,
137 0x505050505ll);
138 if (y != ((0x130000029ll & (0x064000008ll << 3))))
139 abort ();
141 y = ands_di_test3 (0x130002900ll,
142 0x088000008ll,
143 0x505050505ll);
144 if (y != (0x130002900ll + 0x505050505ll))
145 abort ();
147 return 0;