[GlobalISel] Avoid repeated hash lookups (NFC) (#124393)
[llvm-project.git] / compiler-rt / test / builtins / Unit / umodti3_test.c
blob6efeb51a6252d2ecbe6dfd2cbedca535cb43b6ae
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_umodti3
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 tu_int __umodti3(tu_int a, tu_int b);
14 int test__umodti3(tu_int a, tu_int b, tu_int expected_r)
16 tu_int r = __umodti3(a, b);
17 if (r != expected_r)
19 utwords at;
20 at.all = a;
21 utwords bt;
22 bt.all = b;
23 utwords rt;
24 rt.all = r;
25 utwords expected_rt;
26 expected_rt.all = expected_r;
27 printf("error in __umodti3: 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, rt.s.high, rt.s.low,
30 expected_rt.s.high, expected_rt.s.low);
32 return r != expected_r;
35 #endif
37 int main()
39 #ifdef CRT_HAS_128BIT
40 if (test__umodti3(0, 1, 0))
41 return 1;
42 if (test__umodti3(2, 1, 0))
43 return 1;
44 if (test__umodti3(make_tu(0x8000000000000000uLL, 0), 1, 0x0uLL))
45 return 1;
46 if (test__umodti3(make_tu(0x8000000000000000uLL, 0), 2, 0x0uLL))
47 return 1;
48 if (test__umodti3(make_tu(0xFFFFFFFFFFFFFFFFuLL, 0xFFFFFFFFFFFFFFFFuLL),
49 2, 0x1uLL))
50 return 1;
52 #else
53 printf("skipped\n");
54 #endif
55 return 0;