* gcc.target/i386/pr70021.c: Add -mtune=skylake.
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / negs.c
blob1c23041eae769637cb96bfef0ab5da23c11f3268
1 /* { dg-do run } */
2 /* { dg-options "-O2 --save-temps" } */
4 extern void abort (void);
5 int z;
7 int
8 negs_si_test1 (int a, int b, int c)
10 int d = -b;
12 /* { dg-final { scan-assembler "negs\tw\[0-9\]+, w\[0-9\]+" } } */
13 if (d < 0)
14 return a + c;
16 z = d;
17 return b + c + d;
20 int
21 negs_si_test3 (int a, int b, int c)
23 int d = -(b) << 3;
25 /* { dg-final { scan-assembler "negs\tw\[0-9\]+, w\[0-9\]+, lsl 3" } } */
26 if (d == 0)
27 return a + c;
29 z = d;
30 return b + c + d;
33 typedef long long s64;
34 s64 zz;
36 s64
37 negs_di_test1 (s64 a, s64 b, s64 c)
39 s64 d = -b;
41 /* { dg-final { scan-assembler "negs\tx\[0-9\]+, x\[0-9\]+" } } */
42 if (d < 0)
43 return a + c;
45 zz = d;
46 return b + c + d;
49 s64
50 negs_di_test3 (s64 a, s64 b, s64 c)
52 s64 d = -(b) << 3;
54 /* { dg-final { scan-assembler "negs\tx\[0-9\]+, x\[0-9\]+, lsl 3" } } */
55 if (d == 0)
56 return a + c;
58 zz = d;
59 return b + c + d;
62 int main ()
64 int x;
65 s64 y;
67 x = negs_si_test1 (2, 12, 5);
68 if (x != 7)
69 abort ();
71 x = negs_si_test1 (1, 2, 32);
72 if (x != 33)
73 abort ();
75 x = negs_si_test3 (13, 14, 5);
76 if (x != -93)
77 abort ();
79 x = negs_si_test3 (15, 21, 2);
80 if (x != -145)
81 abort ();
83 y = negs_di_test1 (0x20202020ll,
84 0x65161611ll,
85 0x42434243ll);
86 if (y != 0x62636263ll)
87 abort ();
89 y = negs_di_test1 (0x1010101010101ll,
90 0x123456789abcdll,
91 0x5555555555555ll);
92 if (y != 0x6565656565656ll)
93 abort ();
95 y = negs_di_test3 (0x62523781ll,
96 0x64234978ll,
97 0x12345123ll);
98 if (y != 0xfffffffd553d4edbll)
99 abort ();
101 y = negs_di_test3 (0x763526268ll,
102 0x101010101ll,
103 0x222222222ll);
104 if (y != 0xfffffffb1b1b1b1bll)
105 abort ();
107 return 0;