1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_ucmpti2
10 // Returns: if (a < b) returns 0
11 // if (a == b) returns 1
12 // if (a > b) returns 2
14 COMPILER_RT_ABI si_int
__ucmpti2(tu_int a
, tu_int b
);
16 int test__ucmpti2(tu_int a
, tu_int b
, si_int expected
)
18 si_int x
= __ucmpti2(a
, b
);
25 printf("error in __ucmpti2(0x%.16llX%.16llX, 0x%.16llX%.16llX) = %d, "
27 at
.s
.high
, at
.s
.low
, bt
.s
.high
, bt
.s
.low
, x
, expected
);
37 if (test__ucmpti2(0, 0, 1))
39 if (test__ucmpti2(1, 1, 1))
41 if (test__ucmpti2(2, 2, 1))
43 if (test__ucmpti2(0x7FFFFFFF, 0x7FFFFFFF, 1))
45 if (test__ucmpti2(0x80000000, 0x80000000, 1))
47 if (test__ucmpti2(0x80000001, 0x80000001, 1))
49 if (test__ucmpti2(0xFFFFFFFF, 0xFFFFFFFF, 1))
51 if (test__ucmpti2(0x000000010000000LL
, 0x000000010000000LL
, 1))
53 if (test__ucmpti2(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
, 1))
56 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000300000001LL
, 0))
58 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000300000002LL
, 0))
60 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000300000003LL
, 0))
63 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000100000001LL
, 2))
65 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000100000002LL
, 2))
67 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000100000003LL
, 2))
70 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000200000001LL
, 2))
72 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000200000002LL
, 1))
74 if (test__ucmpti2(0x0000000200000002LL
, 0x0000000200000003LL
, 0))
77 if (test__ucmpti2(make_tu(0x0000000000000001uLL
, 0x0000000000000000uLL
),
78 make_tu(0x0000000000000000uLL
, 0xFFFFFFFFFFFFFFFFuLL
), 2))
80 if (test__ucmpti2(make_tu(0x0000000000000001uLL
, 0x0000000000000000uLL
),
81 make_tu(0x0000000000000001uLL
, 0x0000000000000000uLL
), 1))
83 if (test__ucmpti2(make_tu(0x0000000000000001uLL
, 0x0000000000000000uLL
),
84 make_tu(0x0000000000000001uLL
, 0x0000000000000001uLL
), 0))
87 if (test__ucmpti2(make_tu(0x8000000000000000uLL
, 0x0000000000000000uLL
),
88 make_tu(0x7FFFFFFFFFFFFFFFuLL
, 0xFFFFFFFFFFFFFFFFuLL
), 2))
90 if (test__ucmpti2(make_tu(0x8000000000000000uLL
, 0x0000000000000000uLL
),
91 make_tu(0x8000000000000000uLL
, 0x0000000000000000uLL
), 1))
93 if (test__ucmpti2(make_tu(0x8000000000000000uLL
, 0x0000000000000000uLL
),
94 make_tu(0x8000000000000000uLL
, 0x0000000000000001uLL
), 0))
97 if (test__ucmpti2(make_tu(0xFFFFFFFFFFFFFFFFuLL
, 0xFFFFFFFFFFFFFFFFuLL
),
98 make_tu(0xFFFFFFFFFFFFFFFFuLL
, 0xFFFFFFFFFFFFFFFEuLL
), 2))
100 if (test__ucmpti2(make_tu(0xFFFFFFFFFFFFFFFFuLL
, 0xFFFFFFFFFFFFFFFFuLL
),
101 make_tu(0xFFFFFFFFFFFFFFFFuLL
, 0xFFFFFFFFFFFFFFFFuLL
), 1))