Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / builtins / Unit / divdi3_test.c
blobc52f0c1f3868ac21f4daffa92d10a868e1bf365a
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_divdi3
4 #include "int_lib.h"
5 #include <stdio.h>
7 // Returns: a / b
9 COMPILER_RT_ABI di_int __divdi3(di_int a, di_int b);
11 int test__divdi3(di_int a, di_int b, di_int expected)
13 di_int x = __divdi3(a, b);
14 if (x != expected)
15 printf("error in __divdi3: %lld / %lld = %lld, expected %lld\n",
16 a, b, x, expected);
17 return x != expected;
20 char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
22 int main()
24 if (test__divdi3(0, 1, 0))
25 return 1;
26 if (test__divdi3(0, -1, 0))
27 return 1;
29 if (test__divdi3(2, 1, 2))
30 return 1;
31 if (test__divdi3(2, -1, -2))
32 return 1;
33 if (test__divdi3(-2, 1, -2))
34 return 1;
35 if (test__divdi3(-2, -1, 2))
36 return 1;
38 if (test__divdi3(0x8000000000000000LL, 1, 0x8000000000000000LL))
39 return 1;
40 if (test__divdi3(0x8000000000000000LL, -1, 0x8000000000000000LL))
41 return 1;
42 if (test__divdi3(0x8000000000000000LL, -2, 0x4000000000000000LL))
43 return 1;
44 if (test__divdi3(0x8000000000000000LL, 2, 0xC000000000000000LL))
45 return 1;
47 return 0;