1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_umodsi3
3 //===-- umodsi3_test.c - Test __umodsi3 -----------------------------------===//
5 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 // See https://llvm.org/LICENSE.txt for license information.
7 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 //===----------------------------------------------------------------------===//
11 // This file tests __umodsi3 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
20 COMPILER_RT_ABI su_int
__umodsi3(su_int a
, su_int b
);
22 int test__umodsi3(su_int a
, su_int b
, su_int expected_r
)
24 su_int r
= __umodsi3(a
, b
);
26 printf("error in __umodsi3: %X %% %X = %X, expected %X\n",
28 return r
!= expected_r
;
33 {0x00000000, 0x00000001, 0x00000000},
34 {0x00000000, 0x00000002, 0x00000000},
35 {0x00000000, 0x00000003, 0x00000000},
36 {0x00000000, 0x00000010, 0x00000000},
37 {0x00000000, 0x078644FA, 0x00000000},
38 {0x00000000, 0x0747AE14, 0x00000000},
39 {0x00000000, 0x7FFFFFFF, 0x00000000},
40 {0x00000000, 0x80000000, 0x00000000},
41 {0x00000000, 0xFFFFFFFD, 0x00000000},
42 {0x00000000, 0xFFFFFFFE, 0x00000000},
43 {0x00000000, 0xFFFFFFFF, 0x00000000},
44 {0x00000001, 0x00000001, 0x00000000},
45 {0x00000001, 0x00000002, 0x00000001},
46 {0x00000001, 0x00000003, 0x00000001},
47 {0x00000001, 0x00000010, 0x00000001},
48 {0x00000001, 0x078644FA, 0x00000001},
49 {0x00000001, 0x0747AE14, 0x00000001},
50 {0x00000001, 0x7FFFFFFF, 0x00000001},
51 {0x00000001, 0x80000000, 0x00000001},
52 {0x00000001, 0xFFFFFFFD, 0x00000001},
53 {0x00000001, 0xFFFFFFFE, 0x00000001},
54 {0x00000001, 0xFFFFFFFF, 0x00000001},
55 {0x00000002, 0x00000001, 0x00000000},
56 {0x00000002, 0x00000002, 0x00000000},
57 {0x00000002, 0x00000003, 0x00000002},
58 {0x00000002, 0x00000010, 0x00000002},
59 {0x00000002, 0x078644FA, 0x00000002},
60 {0x00000002, 0x0747AE14, 0x00000002},
61 {0x00000002, 0x7FFFFFFF, 0x00000002},
62 {0x00000002, 0x80000000, 0x00000002},
63 {0x00000002, 0xFFFFFFFD, 0x00000002},
64 {0x00000002, 0xFFFFFFFE, 0x00000002},
65 {0x00000002, 0xFFFFFFFF, 0x00000002},
66 {0x00000003, 0x00000001, 0x00000000},
67 {0x00000003, 0x00000002, 0x00000001},
68 {0x00000003, 0x00000003, 0x00000000},
69 {0x00000003, 0x00000010, 0x00000003},
70 {0x00000003, 0x078644FA, 0x00000003},
71 {0x00000003, 0x0747AE14, 0x00000003},
72 {0x00000003, 0x7FFFFFFF, 0x00000003},
73 {0x00000003, 0x80000000, 0x00000003},
74 {0x00000003, 0xFFFFFFFD, 0x00000003},
75 {0x00000003, 0xFFFFFFFE, 0x00000003},
76 {0x00000003, 0xFFFFFFFF, 0x00000003},
77 {0x00000010, 0x00000001, 0x00000000},
78 {0x00000010, 0x00000002, 0x00000000},
79 {0x00000010, 0x00000003, 0x00000001},
80 {0x00000010, 0x00000010, 0x00000000},
81 {0x00000010, 0x078644FA, 0x00000010},
82 {0x00000010, 0x0747AE14, 0x00000010},
83 {0x00000010, 0x7FFFFFFF, 0x00000010},
84 {0x00000010, 0x80000000, 0x00000010},
85 {0x00000010, 0xFFFFFFFD, 0x00000010},
86 {0x00000010, 0xFFFFFFFE, 0x00000010},
87 {0x00000010, 0xFFFFFFFF, 0x00000010},
88 {0x078644FA, 0x00000001, 0x00000000},
89 {0x078644FA, 0x00000002, 0x00000000},
90 {0x078644FA, 0x00000003, 0x00000000},
91 {0x078644FA, 0x00000010, 0x0000000A},
92 {0x078644FA, 0x078644FA, 0x00000000},
93 {0x078644FA, 0x0747AE14, 0x003E96E6},
94 {0x078644FA, 0x7FFFFFFF, 0x078644FA},
95 {0x078644FA, 0x80000000, 0x078644FA},
96 {0x078644FA, 0xFFFFFFFD, 0x078644FA},
97 {0x078644FA, 0xFFFFFFFE, 0x078644FA},
98 {0x078644FA, 0xFFFFFFFF, 0x078644FA},
99 {0x0747AE14, 0x00000001, 0x00000000},
100 {0x0747AE14, 0x00000002, 0x00000000},
101 {0x0747AE14, 0x00000003, 0x00000002},
102 {0x0747AE14, 0x00000010, 0x00000004},
103 {0x0747AE14, 0x078644FA, 0x0747AE14},
104 {0x0747AE14, 0x0747AE14, 0x00000000},
105 {0x0747AE14, 0x7FFFFFFF, 0x0747AE14},
106 {0x0747AE14, 0x80000000, 0x0747AE14},
107 {0x0747AE14, 0xFFFFFFFD, 0x0747AE14},
108 {0x0747AE14, 0xFFFFFFFE, 0x0747AE14},
109 {0x0747AE14, 0xFFFFFFFF, 0x0747AE14},
110 {0x7FFFFFFF, 0x00000001, 0x00000000},
111 {0x7FFFFFFF, 0x00000002, 0x00000001},
112 {0x7FFFFFFF, 0x00000003, 0x00000001},
113 {0x7FFFFFFF, 0x00000010, 0x0000000F},
114 {0x7FFFFFFF, 0x078644FA, 0x00156B65},
115 {0x7FFFFFFF, 0x0747AE14, 0x043D70AB},
116 {0x7FFFFFFF, 0x7FFFFFFF, 0x00000000},
117 {0x7FFFFFFF, 0x80000000, 0x7FFFFFFF},
118 {0x7FFFFFFF, 0xFFFFFFFD, 0x7FFFFFFF},
119 {0x7FFFFFFF, 0xFFFFFFFE, 0x7FFFFFFF},
120 {0x7FFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF},
121 {0x80000000, 0x00000001, 0x00000000},
122 {0x80000000, 0x00000002, 0x00000000},
123 {0x80000000, 0x00000003, 0x00000002},
124 {0x80000000, 0x00000010, 0x00000000},
125 {0x80000000, 0x078644FA, 0x00156B66},
126 {0x80000000, 0x0747AE14, 0x043D70AC},
127 {0x80000000, 0x7FFFFFFF, 0x00000001},
128 {0x80000000, 0x80000000, 0x00000000},
129 {0x80000000, 0xFFFFFFFD, 0x80000000},
130 {0x80000000, 0xFFFFFFFE, 0x80000000},
131 {0x80000000, 0xFFFFFFFF, 0x80000000},
132 {0xFFFFFFFD, 0x00000001, 0x00000000},
133 {0xFFFFFFFD, 0x00000002, 0x00000001},
134 {0xFFFFFFFD, 0x00000003, 0x00000001},
135 {0xFFFFFFFD, 0x00000010, 0x0000000D},
136 {0xFFFFFFFD, 0x078644FA, 0x002AD6C9},
137 {0xFFFFFFFD, 0x0747AE14, 0x01333341},
138 {0xFFFFFFFD, 0x7FFFFFFF, 0x7FFFFFFE},
139 {0xFFFFFFFD, 0x80000000, 0x7FFFFFFD},
140 {0xFFFFFFFD, 0xFFFFFFFD, 0x00000000},
141 {0xFFFFFFFD, 0xFFFFFFFE, 0xFFFFFFFD},
142 {0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFD},
143 {0xFFFFFFFE, 0x00000001, 0x00000000},
144 {0xFFFFFFFE, 0x00000002, 0x00000000},
145 {0xFFFFFFFE, 0x00000003, 0x00000002},
146 {0xFFFFFFFE, 0x00000010, 0x0000000E},
147 {0xFFFFFFFE, 0x078644FA, 0x002AD6CA},
148 {0xFFFFFFFE, 0x0747AE14, 0x01333342},
149 {0xFFFFFFFE, 0x7FFFFFFF, 0x00000000},
150 {0xFFFFFFFE, 0x80000000, 0x7FFFFFFE},
151 {0xFFFFFFFE, 0xFFFFFFFD, 0x00000001},
152 {0xFFFFFFFE, 0xFFFFFFFE, 0x00000000},
153 {0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFE},
154 {0xFFFFFFFF, 0x00000001, 0x00000000},
155 {0xFFFFFFFF, 0x00000002, 0x00000001},
156 {0xFFFFFFFF, 0x00000003, 0x00000000},
157 {0xFFFFFFFF, 0x00000010, 0x0000000F},
158 {0xFFFFFFFF, 0x078644FA, 0x002AD6CB},
159 {0xFFFFFFFF, 0x0747AE14, 0x01333343},
160 {0xFFFFFFFF, 0x7FFFFFFF, 0x00000001},
161 {0xFFFFFFFF, 0x80000000, 0x7FFFFFFF},
162 {0xFFFFFFFF, 0xFFFFFFFD, 0x00000002},
163 {0xFFFFFFFF, 0xFFFFFFFE, 0x00000001},
164 {0xFFFFFFFF, 0xFFFFFFFF, 0x00000000}
169 const unsigned N
= sizeof(tests
) / sizeof(tests
[0]);
171 for (i
= 0; i
< N
; ++i
)
172 if (test__umodsi3(tests
[i
][0], tests
[i
][1], tests
[i
][2]))