1 /* { dg-do run } */
2 /* { dg-options "-madx -O2" } */
3 /* { dg-require-effective-target adx } */
4
5 #include <x86intrin.h>
6 #include "adx-check.h"
7
8 static void
adx_test(void)9 adx_test (void)
10 {
11 volatile unsigned char c;
12 unsigned int x;
13 volatile unsigned int y, sum_ref;
14
15 c = 0;
16 x = y = 0xFFFFFFFF;
17 sum_ref = 0xFFFFFFFE;
18
19 /* X = 0xFFFFFFFF, Y = 0xFFFFFFFF, C = 0. */
20 c = _addcarryx_u32 (c, x, y, &x);
21 /* X = 0xFFFFFFFE, Y = 0xFFFFFFFF, C = 1. */
22 c = _addcarryx_u32 (c, x, y, &x);
23 /* X = 0xFFFFFFFE, Y = 0xFFFFFFFF, C = 1. */
24
25 if (x != sum_ref)
26 abort ();
27
28 c = 0;
29 x = y = 0xFFFFFFFF;
30 sum_ref = 0xFFFFFFFE;
31
32 /* X = 0xFFFFFFFF, Y = 0xFFFFFFFF, C = 0. */
33 c = _addcarry_u32 (c, x, y, &x);
34 /* X = 0xFFFFFFFE, Y = 0xFFFFFFFF, C = 1. */
35 c = _addcarry_u32 (c, x, y, &x);
36 /* X = 0xFFFFFFFE, Y = 0xFFFFFFFF, C = 1. */
37
38 if (x != sum_ref)
39 abort ();
40
41 c = 0;
42 x = 1;
43 y = 0;
44 sum_ref = 0x0;
45
46 /* X = 0x00000001, Y = 0x00000000, C = 0. */
47 c = _subborrow_u32 (c, y, x, &x);
48 /* X = 0xFFFFFFFF, Y = 0x00000000, C = 1. */
49 c = _subborrow_u32 (c, y, x, &x);
50 /* X = 0xFFFFFFFF, Y = 0xFFFFFFFF, C = 1. */
51
52 if (x != sum_ref)
53 abort ();
54 }
55