1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_absvsi2
8 // Returns: absolute value
10 // Effects: aborts if abs(x) < 0
12 COMPILER_RT_ABI si_int
__absvsi2(si_int a
);
14 int test__absvsi2(si_int a
)
16 si_int x
= __absvsi2(a
);
20 if (x
!= expected
|| expected
< 0)
21 printf("error in __absvsi2(0x%X) = %d, expected positive %d\n",
28 // if (test__absvsi2(0x80000000)) // should abort
30 if (test__absvsi2(0x00000000))
32 if (test__absvsi2(0x00000001))
34 if (test__absvsi2(0x00000002))
36 if (test__absvsi2(0x7FFFFFFE))
38 if (test__absvsi2(0x7FFFFFFF))
40 if (test__absvsi2(0x80000001))
42 if (test__absvsi2(0x80000002))
44 if (test__absvsi2(0xFFFFFFFE))
46 if (test__absvsi2(0xFFFFFFFF))
50 for (i
= 0; i
< 10000; ++i
)
51 if (test__absvsi2(rand()))