Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / builtins / Unit / udivmodsi4_test.c
bloba405a459ee165966df574643d8a9dc67c2f89d8c
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_udivmodsi4
4 #include "int_lib.h"
5 #include <stdio.h>
7 // Returns: a / b
9 extern COMPILER_RT_ABI su_int __udivmodsi4(su_int a, su_int b, su_int* rem);
11 int test__udivmodsi4(su_int a, su_int b,
12 su_int expected_result, su_int expected_rem)
14 su_int rem;
15 su_int result = __udivmodsi4(a, b, &rem);
16 if (result != expected_result) {
17 printf("error in __udivmodsi4: %u / %u = %u, expected %u\n",
18 a, b, result, expected_result);
19 return 1;
21 if (rem != expected_rem) {
22 printf("error in __udivmodsi4: %u mod %u = %u, expected %u\n",
23 a, b, rem, expected_rem);
24 return 1;
27 return 0;
31 int main()
33 if (test__udivmodsi4(0, 1, 0, 0))
34 return 1;
36 if (test__udivmodsi4(2, 1, 2, 0))
37 return 1;
39 if (test__udivmodsi4(19, 5, 3, 4))
40 return 1;
42 if (test__udivmodsi4(0x80000000, 8, 0x10000000, 0))
43 return 1;
45 if (test__udivmodsi4(0x80000003, 8, 0x10000000, 3))
46 return 1;
48 return 0;