1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_umodsi3
9 COMPILER_RT_ABI su_int
__umodsi3(su_int a
, su_int b
);
11 int test__umodsi3(su_int a
, su_int b
, su_int expected_r
)
13 su_int r
= __umodsi3(a
, b
);
15 printf("error in __umodsi3: %X %% %X = %X, expected %X\n",
17 return r
!= expected_r
;
22 {0x00000000, 0x00000001, 0x00000000},
23 {0x00000000, 0x00000002, 0x00000000},
24 {0x00000000, 0x00000003, 0x00000000},
25 {0x00000000, 0x00000010, 0x00000000},
26 {0x00000000, 0x078644FA, 0x00000000},
27 {0x00000000, 0x0747AE14, 0x00000000},
28 {0x00000000, 0x7FFFFFFF, 0x00000000},
29 {0x00000000, 0x80000000, 0x00000000},
30 {0x00000000, 0xFFFFFFFD, 0x00000000},
31 {0x00000000, 0xFFFFFFFE, 0x00000000},
32 {0x00000000, 0xFFFFFFFF, 0x00000000},
33 {0x00000001, 0x00000001, 0x00000000},
34 {0x00000001, 0x00000002, 0x00000001},
35 {0x00000001, 0x00000003, 0x00000001},
36 {0x00000001, 0x00000010, 0x00000001},
37 {0x00000001, 0x078644FA, 0x00000001},
38 {0x00000001, 0x0747AE14, 0x00000001},
39 {0x00000001, 0x7FFFFFFF, 0x00000001},
40 {0x00000001, 0x80000000, 0x00000001},
41 {0x00000001, 0xFFFFFFFD, 0x00000001},
42 {0x00000001, 0xFFFFFFFE, 0x00000001},
43 {0x00000001, 0xFFFFFFFF, 0x00000001},
44 {0x00000002, 0x00000001, 0x00000000},
45 {0x00000002, 0x00000002, 0x00000000},
46 {0x00000002, 0x00000003, 0x00000002},
47 {0x00000002, 0x00000010, 0x00000002},
48 {0x00000002, 0x078644FA, 0x00000002},
49 {0x00000002, 0x0747AE14, 0x00000002},
50 {0x00000002, 0x7FFFFFFF, 0x00000002},
51 {0x00000002, 0x80000000, 0x00000002},
52 {0x00000002, 0xFFFFFFFD, 0x00000002},
53 {0x00000002, 0xFFFFFFFE, 0x00000002},
54 {0x00000002, 0xFFFFFFFF, 0x00000002},
55 {0x00000003, 0x00000001, 0x00000000},
56 {0x00000003, 0x00000002, 0x00000001},
57 {0x00000003, 0x00000003, 0x00000000},
58 {0x00000003, 0x00000010, 0x00000003},
59 {0x00000003, 0x078644FA, 0x00000003},
60 {0x00000003, 0x0747AE14, 0x00000003},
61 {0x00000003, 0x7FFFFFFF, 0x00000003},
62 {0x00000003, 0x80000000, 0x00000003},
63 {0x00000003, 0xFFFFFFFD, 0x00000003},
64 {0x00000003, 0xFFFFFFFE, 0x00000003},
65 {0x00000003, 0xFFFFFFFF, 0x00000003},
66 {0x00000010, 0x00000001, 0x00000000},
67 {0x00000010, 0x00000002, 0x00000000},
68 {0x00000010, 0x00000003, 0x00000001},
69 {0x00000010, 0x00000010, 0x00000000},
70 {0x00000010, 0x078644FA, 0x00000010},
71 {0x00000010, 0x0747AE14, 0x00000010},
72 {0x00000010, 0x7FFFFFFF, 0x00000010},
73 {0x00000010, 0x80000000, 0x00000010},
74 {0x00000010, 0xFFFFFFFD, 0x00000010},
75 {0x00000010, 0xFFFFFFFE, 0x00000010},
76 {0x00000010, 0xFFFFFFFF, 0x00000010},
77 {0x078644FA, 0x00000001, 0x00000000},
78 {0x078644FA, 0x00000002, 0x00000000},
79 {0x078644FA, 0x00000003, 0x00000000},
80 {0x078644FA, 0x00000010, 0x0000000A},
81 {0x078644FA, 0x078644FA, 0x00000000},
82 {0x078644FA, 0x0747AE14, 0x003E96E6},
83 {0x078644FA, 0x7FFFFFFF, 0x078644FA},
84 {0x078644FA, 0x80000000, 0x078644FA},
85 {0x078644FA, 0xFFFFFFFD, 0x078644FA},
86 {0x078644FA, 0xFFFFFFFE, 0x078644FA},
87 {0x078644FA, 0xFFFFFFFF, 0x078644FA},
88 {0x0747AE14, 0x00000001, 0x00000000},
89 {0x0747AE14, 0x00000002, 0x00000000},
90 {0x0747AE14, 0x00000003, 0x00000002},
91 {0x0747AE14, 0x00000010, 0x00000004},
92 {0x0747AE14, 0x078644FA, 0x0747AE14},
93 {0x0747AE14, 0x0747AE14, 0x00000000},
94 {0x0747AE14, 0x7FFFFFFF, 0x0747AE14},
95 {0x0747AE14, 0x80000000, 0x0747AE14},
96 {0x0747AE14, 0xFFFFFFFD, 0x0747AE14},
97 {0x0747AE14, 0xFFFFFFFE, 0x0747AE14},
98 {0x0747AE14, 0xFFFFFFFF, 0x0747AE14},
99 {0x7FFFFFFF, 0x00000001, 0x00000000},
100 {0x7FFFFFFF, 0x00000002, 0x00000001},
101 {0x7FFFFFFF, 0x00000003, 0x00000001},
102 {0x7FFFFFFF, 0x00000010, 0x0000000F},
103 {0x7FFFFFFF, 0x078644FA, 0x00156B65},
104 {0x7FFFFFFF, 0x0747AE14, 0x043D70AB},
105 {0x7FFFFFFF, 0x7FFFFFFF, 0x00000000},
106 {0x7FFFFFFF, 0x80000000, 0x7FFFFFFF},
107 {0x7FFFFFFF, 0xFFFFFFFD, 0x7FFFFFFF},
108 {0x7FFFFFFF, 0xFFFFFFFE, 0x7FFFFFFF},
109 {0x7FFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF},
110 {0x80000000, 0x00000001, 0x00000000},
111 {0x80000000, 0x00000002, 0x00000000},
112 {0x80000000, 0x00000003, 0x00000002},
113 {0x80000000, 0x00000010, 0x00000000},
114 {0x80000000, 0x078644FA, 0x00156B66},
115 {0x80000000, 0x0747AE14, 0x043D70AC},
116 {0x80000000, 0x7FFFFFFF, 0x00000001},
117 {0x80000000, 0x80000000, 0x00000000},
118 {0x80000000, 0xFFFFFFFD, 0x80000000},
119 {0x80000000, 0xFFFFFFFE, 0x80000000},
120 {0x80000000, 0xFFFFFFFF, 0x80000000},
121 {0xFFFFFFFD, 0x00000001, 0x00000000},
122 {0xFFFFFFFD, 0x00000002, 0x00000001},
123 {0xFFFFFFFD, 0x00000003, 0x00000001},
124 {0xFFFFFFFD, 0x00000010, 0x0000000D},
125 {0xFFFFFFFD, 0x078644FA, 0x002AD6C9},
126 {0xFFFFFFFD, 0x0747AE14, 0x01333341},
127 {0xFFFFFFFD, 0x7FFFFFFF, 0x7FFFFFFE},
128 {0xFFFFFFFD, 0x80000000, 0x7FFFFFFD},
129 {0xFFFFFFFD, 0xFFFFFFFD, 0x00000000},
130 {0xFFFFFFFD, 0xFFFFFFFE, 0xFFFFFFFD},
131 {0xFFFFFFFD, 0xFFFFFFFF, 0xFFFFFFFD},
132 {0xFFFFFFFE, 0x00000001, 0x00000000},
133 {0xFFFFFFFE, 0x00000002, 0x00000000},
134 {0xFFFFFFFE, 0x00000003, 0x00000002},
135 {0xFFFFFFFE, 0x00000010, 0x0000000E},
136 {0xFFFFFFFE, 0x078644FA, 0x002AD6CA},
137 {0xFFFFFFFE, 0x0747AE14, 0x01333342},
138 {0xFFFFFFFE, 0x7FFFFFFF, 0x00000000},
139 {0xFFFFFFFE, 0x80000000, 0x7FFFFFFE},
140 {0xFFFFFFFE, 0xFFFFFFFD, 0x00000001},
141 {0xFFFFFFFE, 0xFFFFFFFE, 0x00000000},
142 {0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFE},
143 {0xFFFFFFFF, 0x00000001, 0x00000000},
144 {0xFFFFFFFF, 0x00000002, 0x00000001},
145 {0xFFFFFFFF, 0x00000003, 0x00000000},
146 {0xFFFFFFFF, 0x00000010, 0x0000000F},
147 {0xFFFFFFFF, 0x078644FA, 0x002AD6CB},
148 {0xFFFFFFFF, 0x0747AE14, 0x01333343},
149 {0xFFFFFFFF, 0x7FFFFFFF, 0x00000001},
150 {0xFFFFFFFF, 0x80000000, 0x7FFFFFFF},
151 {0xFFFFFFFF, 0xFFFFFFFD, 0x00000002},
152 {0xFFFFFFFF, 0xFFFFFFFE, 0x00000001},
153 {0xFFFFFFFF, 0xFFFFFFFF, 0x00000000}
158 const unsigned N
= sizeof(tests
) / sizeof(tests
[0]);
160 for (i
= 0; i
< N
; ++i
)
161 if (test__umodsi3(tests
[i
][0], tests
[i
][1], tests
[i
][2]))