[NFC][TableGen] Code cleanup in CodeGenTarget.cpp (#125569)
[llvm-project.git] / compiler-rt / test / builtins / Unit / multi3_test.c
blob684039200db0839d7919687419891044db381fc1
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_multi3
3 // REQUIRES: int128
5 #include "int_lib.h"
6 #include <stdio.h>
8 #ifdef CRT_HAS_128BIT
10 COMPILER_RT_ABI ti_int __multi3(ti_int a, ti_int b);
12 int test__multi3(ti_int a, ti_int b, ti_int expected)
14 ti_int x = __multi3(a, b);
15 if (x != expected)
17 twords at;
18 at.all = a;
19 twords bt;
20 bt.all = b;
21 twords xt;
22 xt.all = x;
23 twords expectedt;
24 expectedt.all = expected;
25 printf("error in __multi3: 0x%.16llX%.16llX * 0x%.16llX%.16llX = "
26 "0x%.16llX%.16llX, expected 0x%.16llX%.16llX\n",
27 at.s.high, at.s.low, bt.s.high, bt.s.low, xt.s.high, xt.s.low,
28 expectedt.s.high, expectedt.s.low);
30 return x != expected;
33 char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
35 #endif
37 int main()
39 #ifdef CRT_HAS_128BIT
40 if (test__multi3(0, 0, 0))
41 return 1;
42 if (test__multi3(0, 1, 0))
43 return 1;
44 if (test__multi3(1, 0, 0))
45 return 1;
46 if (test__multi3(0, 10, 0))
47 return 1;
48 if (test__multi3(10, 0, 0))
49 return 1;
50 if (test__multi3(0, 81985529216486895LL, 0))
51 return 1;
52 if (test__multi3(81985529216486895LL, 0, 0))
53 return 1;
55 if (test__multi3(0, -1, 0))
56 return 1;
57 if (test__multi3(-1, 0, 0))
58 return 1;
59 if (test__multi3(0, -10, 0))
60 return 1;
61 if (test__multi3(-10, 0, 0))
62 return 1;
63 if (test__multi3(0, -81985529216486895LL, 0))
64 return 1;
65 if (test__multi3(-81985529216486895LL, 0, 0))
66 return 1;
68 if (test__multi3(1, 1, 1))
69 return 1;
70 if (test__multi3(1, 10, 10))
71 return 1;
72 if (test__multi3(10, 1, 10))
73 return 1;
74 if (test__multi3(1, 81985529216486895LL, 81985529216486895LL))
75 return 1;
76 if (test__multi3(81985529216486895LL, 1, 81985529216486895LL))
77 return 1;
79 if (test__multi3(1, -1, -1))
80 return 1;
81 if (test__multi3(1, -10, -10))
82 return 1;
83 if (test__multi3(-10, 1, -10))
84 return 1;
85 if (test__multi3(1, -81985529216486895LL, -81985529216486895LL))
86 return 1;
87 if (test__multi3(-81985529216486895LL, 1, -81985529216486895LL))
88 return 1;
90 if (test__multi3(3037000499LL, 3037000499LL, 9223372030926249001LL))
91 return 1;
92 if (test__multi3(-3037000499LL, 3037000499LL, -9223372030926249001LL))
93 return 1;
94 if (test__multi3(3037000499LL, -3037000499LL, -9223372030926249001LL))
95 return 1;
96 if (test__multi3(-3037000499LL, -3037000499LL, 9223372030926249001LL))
97 return 1;
99 if (test__multi3(4398046511103LL, 2097152LL, 9223372036852678656LL))
100 return 1;
101 if (test__multi3(-4398046511103LL, 2097152LL, -9223372036852678656LL))
102 return 1;
103 if (test__multi3(4398046511103LL, -2097152LL, -9223372036852678656LL))
104 return 1;
105 if (test__multi3(-4398046511103LL, -2097152LL, 9223372036852678656LL))
106 return 1;
108 if (test__multi3(2097152LL, 4398046511103LL, 9223372036852678656LL))
109 return 1;
110 if (test__multi3(-2097152LL, 4398046511103LL, -9223372036852678656LL))
111 return 1;
112 if (test__multi3(2097152LL, -4398046511103LL, -9223372036852678656LL))
113 return 1;
114 if (test__multi3(-2097152LL, -4398046511103LL, 9223372036852678656LL))
115 return 1;
117 if (test__multi3(make_ti(0x00000000000000B5LL, 0x04F333F9DE5BE000LL),
118 make_ti(0x0000000000000000LL, 0x00B504F333F9DE5BLL),
119 make_ti(0x7FFFFFFFFFFFF328LL, 0xDF915DA296E8A000LL)))
120 return 1;
121 #else
122 printf("skipped\n");
123 #endif
124 return 0;