[AMDGPU] Remove s_wakeup_barrier instruction (#122277)
[llvm-project.git] / compiler-rt / test / builtins / Unit / divti3_test.c
blobb43f9241fb9ce80750b4e7dac31442848405b4ef
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_divti3
3 // REQUIRES: int128
5 #include "int_lib.h"
6 #include <stdio.h>
8 #ifdef CRT_HAS_128BIT
10 // Returns: a / b
12 COMPILER_RT_ABI ti_int __divti3(ti_int a, ti_int b);
14 int test__divti3(ti_int a, ti_int b, ti_int expected)
16 ti_int x = __divti3(a, b);
17 if (x != expected)
19 twords at;
20 at.all = a;
21 twords bt;
22 bt.all = b;
23 twords xt;
24 xt.all = x;
25 twords expectedt;
26 expectedt.all = expected;
27 printf("error in __divti3: 0x%llX%.16llX / 0x%llX%.16llX = "
28 "0x%llX%.16llX, expected 0x%llX%.16llX\n",
29 at.s.high, at.s.low, bt.s.high, bt.s.low, xt.s.high, xt.s.low,
30 expectedt.s.high, expectedt.s.low);
32 return x != expected;
35 char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
37 #endif
39 int main()
41 #ifdef CRT_HAS_128BIT
42 if (test__divti3(0, 1, 0))
43 return 1;
44 if (test__divti3(0, -1, 0))
45 return 1;
47 if (test__divti3(2, 1, 2))
48 return 1;
49 if (test__divti3(2, -1, -2))
50 return 1;
51 if (test__divti3(-2, 1, -2))
52 return 1;
53 if (test__divti3(-2, -1, 2))
54 return 1;
56 if (test__divti3(make_ti(0x8000000000000000LL, 0), 1, make_ti(0x8000000000000000LL, 0)))
57 return 1;
58 if (test__divti3(make_ti(0x8000000000000000LL, 0), -1, make_ti(0x8000000000000000LL, 0)))
59 return 1;
60 if (test__divti3(make_ti(0x8000000000000000LL, 0), -2, make_ti(0x4000000000000000LL, 0)))
61 return 1;
62 if (test__divti3(make_ti(0x8000000000000000LL, 0), 2, make_ti(0xC000000000000000LL, 0)))
63 return 1;
65 #else
66 printf("skipped\n");
67 #endif
68 return 0;