brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 054776e Raw
76 lines · c
1// RUN: %clang_builtins %s %librt -o %t && %run %t2// REQUIRES: librt_has_ctzti23// REQUIRES: int1284 5#include "int_lib.h"6#include <stdio.h>7 8#ifdef CRT_HAS_128BIT9 10// Returns: the number of trailing 0-bits11 12// Precondition: a != 013 14COMPILER_RT_ABI int __ctzti2(ti_int a);15 16int test__ctzti2(ti_int a, int expected)17{18    int x = __ctzti2(a);19    if (x != expected)20    {21        twords at;22        at.all = a;23        printf("error in __ctzti2(0x%llX%.16llX) = %d, expected %d\n",24               at.s.high, at.s.low, x, expected);25    }26    return x != expected;27}28 29char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};30 31#endif32 33int main()34{35#ifdef CRT_HAS_128BIT36    if (test__ctzti2(0x00000001, 0))37        return 1;38    if (test__ctzti2(0x00000002, 1))39        return 1;40    if (test__ctzti2(0x00000003, 0))41        return 1;42    if (test__ctzti2(0x00000004, 2))43        return 1;44    if (test__ctzti2(0x00000005, 0))45        return 1;46    if (test__ctzti2(0x0000000A, 1))47        return 1;48    if (test__ctzti2(0x10000000, 28))49        return 1;50    if (test__ctzti2(0x20000000, 29))51        return 1;52    if (test__ctzti2(0x60000000, 29))53        return 1;54    if (test__ctzti2(0x80000000uLL, 31))55        return 1;56    if (test__ctzti2(0x0000050000000000uLL, 40))57        return 1;58    if (test__ctzti2(0x0200080000000000uLL, 43))59        return 1;60    if (test__ctzti2(0x7200000000000000uLL, 57))61        return 1;62    if (test__ctzti2(0x8000000000000000uLL, 63))63        return 1;64    if (test__ctzti2(make_ti(0x00000000A0000000LL, 0x0000000000000000LL), 93))65        return 1;66    if (test__ctzti2(make_ti(0xF000000000000000LL, 0x0000000000000000LL), 124))67        return 1;68    if (test__ctzti2(make_ti(0x8000000000000000LL, 0x0000000000000000LL), 127))69        return 1;70#else71    printf("skipped\n");72#endif73 74   return 0;75}76