104 lines · c
1// RUN: %clang_builtins %s %librt -o %t && %run %t2// REQUIRES: librt_has_cmpti23// REQUIRES: int1284 5#include "int_lib.h"6#include <stdio.h>7 8#ifdef CRT_HAS_128BIT9 10// Returns: if (a < b) returns 011// if (a == b) returns 112// if (a > b) returns 213 14COMPILER_RT_ABI si_int __cmpti2(ti_int a, ti_int b);15 16int test__cmpti2(ti_int a, ti_int b, si_int expected)17{18 si_int x = __cmpti2(a, b);19 if (x != expected)20 {21 twords at;22 at.all = a;23 twords bt;24 bt.all = b;25 printf("error in __cmpti2(0x%llX%.16llX, 0x%llX%.16llX) = %d, expected %d\n",26 at.s.high, at.s.low, bt.s.high, bt.s.low, x, expected);27 }28 return x != expected;29}30 31char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};32 33#endif34 35int main()36{37#ifdef CRT_HAS_128BIT38 if (test__cmpti2(0, 0, 1))39 return 1;40 if (test__cmpti2(1, 1, 1))41 return 1;42 if (test__cmpti2(2, 2, 1))43 return 1;44 if (test__cmpti2(0x7FFFFFFF, 0x7FFFFFFF, 1))45 return 1;46 if (test__cmpti2(0x80000000, 0x80000000, 1))47 return 1;48 if (test__cmpti2(0x80000001, 0x80000001, 1))49 return 1;50 if (test__cmpti2(0xFFFFFFFF, 0xFFFFFFFF, 1))51 return 1;52 if (test__cmpti2(0x000000010000000LL, 0x000000010000000LL, 1))53 return 1;54 if (test__cmpti2(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 1))55 return 1;56 57 if (test__cmpti2(0x0000000200000002LL, 0x0000000300000001LL, 0))58 return 1;59 if (test__cmpti2(0x0000000200000002LL, 0x0000000300000002LL, 0))60 return 1;61 if (test__cmpti2(0x0000000200000002LL, 0x0000000300000003LL, 0))62 return 1;63 64 if (test__cmpti2(0x0000000200000002LL, 0x0000000100000001LL, 2))65 return 1;66 if (test__cmpti2(0x0000000200000002LL, 0x0000000100000002LL, 2))67 return 1;68 if (test__cmpti2(0x0000000200000002LL, 0x0000000100000003LL, 2))69 return 1;70 71 if (test__cmpti2(0x0000000200000002LL, 0x0000000200000001LL, 2))72 return 1;73 if (test__cmpti2(0x0000000200000002LL, 0x0000000200000002LL, 1))74 return 1;75 if (test__cmpti2(0x0000000200000002LL, 0x0000000200000003LL, 0))76 return 1;77 78 if (test__cmpti2(make_ti(2, 2), make_ti(3, 1), 0))79 return 1;80 if (test__cmpti2(make_ti(2, 2), make_ti(3, 2), 0))81 return 1;82 if (test__cmpti2(make_ti(2, 2), make_ti(3, 3), 0))83 return 1;84 85 if (test__cmpti2(make_ti(2, 2), make_ti(1, 1), 2))86 return 1;87 if (test__cmpti2(make_ti(2, 2), make_ti(1, 2), 2))88 return 1;89 if (test__cmpti2(make_ti(2, 2), make_ti(1, 3), 2))90 return 1;91 92 if (test__cmpti2(make_ti(2, 2), make_ti(2, 1), 2))93 return 1;94 if (test__cmpti2(make_ti(2, 2), make_ti(2, 2), 1))95 return 1;96 if (test__cmpti2(make_ti(2, 2), make_ti(2, 3), 0))97 return 1;98 99#else100 printf("skipped\n");101#endif102 return 0;103}104