1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_absvti2
11 // Returns: absolute value
13 // Effects: aborts if abs(x) < 0
15 COMPILER_RT_ABI ti_int
__absvti2(ti_int a
);
17 int test__absvti2(ti_int a
)
19 ti_int x
= __absvti2(a
);
23 if (x
!= expected
|| expected
< 0)
30 expectedt
.all
= expected
;
31 printf("error in __absvti2(0x%llX%.16llX) = "
32 "0x%llX%.16llX, expected positive 0x%llX%.16llX\n",
33 at
.s
.high
, at
.s
.low
, xt
.s
.high
, xt
.s
.low
,
34 expectedt
.s
.high
, expectedt
.s
.low
);
45 // if (test__absvti2(make_ti(0x8000000000000000LL, 0))) // should abort
47 if (test__absvti2(0x0000000000000000LL
))
49 if (test__absvti2(0x0000000000000001LL
))
51 if (test__absvti2(0x0000000000000002LL
))
53 if (test__absvti2(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFELL
)))
55 if (test__absvti2(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
57 if (test__absvti2(make_ti(0x8000000000000000LL
, 0x0000000000000001LL
)))
59 if (test__absvti2(make_ti(0x8000000000000000LL
, 0x0000000000000002LL
)))
61 if (test__absvti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFELL
)))
63 if (test__absvti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
67 for (i
= 0; i
< 10000; ++i
)
68 if (test__absvti2(make_ti(((ti_int
)rand() << 32) | rand(),
69 ((ti_int
)rand() << 32) | rand())))