1 //===-- ucmpti2_test.c - Test __ucmpti2 -----------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file tests __ucmpti2 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
19 // Returns: if (a < b) returns 0
20 // if (a == b) returns 1
21 // if (a > b) returns 2
23 si_int
__ucmpti2(tu_int a
, tu_int b
);
25 int test__ucmpti2(tu_int a
, tu_int b
, si_int expected
)
27 si_int x
= __ucmpti2(a
, b
);
34 printf("error in __ucmpti2(0x%.16llX%.16llX, 0x%.16llX%.16llX) = %d, "
36 at
.s
.high
, at
.s
.low
, bt
.s
.high
, bt
.s
.low
, x
, expected
);
46 if (test__ucmpti2(0, 0, 1))
48 if (test__ucmpti2(1, 1, 1))
50 if (test__ucmpti2(2, 2, 1))
52 if (test__ucmpti2(0x7FFFFFFF, 0x7FFFFFFF, 1))
54 if (test__ucmpti2(0x80000000, 0x80000000, 1))
56 if (test__ucmpti2(0x80000001, 0x80000001, 1))
58 if (test__ucmpti2(0xFFFFFFFF, 0xFFFFFFFF, 1))
60 if (test__ucmpti2(0x000000010000000LL
, 0x000000010000000LL
, 1))
62 if (test__ucmpti2(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
, 1))
65 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000300000001LL
, 0))
67 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000300000002LL
, 0))
69 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000300000003LL
, 0))
72 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000100000001LL
, 2))
74 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000100000002LL
, 2))
76 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000100000003LL
, 2))
79 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000200000001LL
, 2))
81 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000200000002LL
, 1))
83 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000200000003LL
, 0))
86 if (test__ucmpti2(make_tu(0x0000000000000001uLL
, 0x0000000000000000uLL
),
87 make_tu(0x0000000000000000uLL
, 0xFFFFFFFFFFFFFFFFuLL
), 2))
89 if (test__ucmpti2(make_tu(0x0000000000000001uLL
, 0x0000000000000000uLL
),
90 make_tu(0x0000000000000001uLL
, 0x0000000000000000uLL
), 1))
92 if (test__ucmpti2(make_tu(0x0000000000000001uLL
, 0x0000000000000000uLL
),
93 make_tu(0x0000000000000001uLL
, 0x0000000000000001uLL
), 0))
96 if (test__ucmpti2(make_tu(0x8000000000000000uLL
, 0x0000000000000000uLL
),
97 make_tu(0x7FFFFFFFFFFFFFFFuLL
, 0xFFFFFFFFFFFFFFFFuLL
), 2))
99 if (test__ucmpti2(make_tu(0x8000000000000000uLL
, 0x0000000000000000uLL
),
100 make_tu(0x8000000000000000uLL
, 0x0000000000000000uLL
), 1))
102 if (test__ucmpti2(make_tu(0x8000000000000000uLL
, 0x0000000000000000uLL
),
103 make_tu(0x8000000000000000uLL
, 0x0000000000000001uLL
), 0))
106 if (test__ucmpti2(make_tu(0xFFFFFFFFFFFFFFFFuLL
, 0xFFFFFFFFFFFFFFFFuLL
),
107 make_tu(0xFFFFFFFFFFFFFFFFuLL
, 0xFFFFFFFFFFFFFFFEuLL
), 2))
109 if (test__ucmpti2(make_tu(0xFFFFFFFFFFFFFFFFuLL
, 0xFFFFFFFFFFFFFFFFuLL
),
110 make_tu(0xFFFFFFFFFFFFFFFFuLL
, 0xFFFFFFFFFFFFFFFFuLL
), 1))