* config/i386/avx512fintrin.h (_mm512_set_epi16, _mm512_set_epi8,
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / subs1.c
blobebfc17f4e7a42ebe4f193f17812792ff306610e4
1 /* { dg-do run } */
2 /* { dg-options "-O2 --save-temps -fno-inline" } */
4 extern void abort (void);
6 int
7 subs_si_test1 (int a, int b, int c)
9 int d = a - c;
11 /* { dg-final { scan-assembler "subs\tw\[0-9\]+, w\[0-9\]+, w\[0-9\]+" } } */
12 if (d == 0)
13 return a + c;
14 else
15 return d;
18 int
19 subs_si_test2 (int a, int b, int c)
21 int d = a - 0xff;
23 /* { dg-final { scan-assembler "subs\tw\[0-9\]+, w\[0-9\]+, #255" } } */
24 if (d == 0)
25 return a + c;
26 else
27 return d;
30 int
31 subs_si_test3 (int a, int b, int c)
33 int d = a - (b << 3);
35 /* { dg-final { scan-assembler "subs\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 subs_di_test1 (s64 a, s64 b, s64 c)
47 s64 d = a - c;
49 /* { dg-final { scan-assembler "subs\tx\[0-9\]+, x\[0-9\]+, x\[0-9\]+" } } */
50 if (d == 0)
51 return a + c;
52 else
53 return d;
56 s64
57 subs_di_test2 (s64 a, s64 b, s64 c)
59 s64 d = a - 0xff;
61 /* { dg-final { scan-assembler "subs\tx\[0-9\]+, x\[0-9\]+, #255" } } */
62 if (d == 0)
63 return a + c;
64 else
65 return d;
68 s64
69 subs_di_test3 (s64 a, s64 b, s64 c)
71 s64 d = a - (b << 3);
73 /* { dg-final { scan-assembler "subs\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 main ()
82 int x;
83 s64 y;
85 x = subs_si_test1 (29, 4, 5);
86 if (x != 24)
87 abort ();
89 x = subs_si_test1 (20, 2, 20);
90 if (x != 40)
91 abort ();
93 x = subs_si_test2 (0xff, 4, 5);
94 if (x != (0xff + 5))
95 abort ();
97 x = subs_si_test2 (1024, 2, 20);
98 if (x != (1024 - 0xff))
99 abort ();
101 x = subs_si_test3 (35, 4, 5);
102 if (x != 35 - (4 << 3))
103 abort ();
105 x = subs_si_test3 (5 << 3, 5, 20);
106 if (x != (20 + (5 << 3)))
107 abort ();
109 y = subs_di_test1 (0x130000029ll,
110 0x320000004ll,
111 0x505050505ll);
113 if (y != (0x130000029ll - 0x505050505ll))
114 abort ();
116 y = subs_di_test1 (0x5000500050005ll,
117 0x2111211121112ll,
118 0x5000500050005ll);
119 if (y != (0x5000500050005ll + 0x5000500050005ll))
120 abort ();
122 y = subs_di_test2 (0x130000029ll,
123 0x320000004ll,
124 0x505050505ll);
125 if (y != (0x130000029ll - 0xff))
126 abort ();
128 y = subs_di_test2 (0xff,
129 0x320000004ll,
130 0x505050505ll);
131 if (y != (0xff + 0x505050505ll))
132 abort ();
134 y = subs_di_test3 (0x130000029ll,
135 0x064000008ll,
136 0x505050505ll);
137 if (y != (0x130000029ll - (0x064000008ll << 3)))
138 abort ();
140 y = subs_di_test3 (0x130002900ll << 3,
141 0x130002900ll,
142 0x505050505ll);
143 if (y != (0x505050505ll + (0x130002900ll << 3)))
144 abort ();
146 return 0;