Home | History | Annotate | Download | only in Unit
      1 //===-- ctzdi2_test.c - Test __ctzdi2 -------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file tests __ctzdi2 for the compiler_rt library.
     11 //
     12 //===----------------------------------------------------------------------===//
     13 
     14 #include "int_lib.h"
     15 #include <stdio.h>
     16 
     17 // Returns: the number of trailing 0-bits
     18 
     19 // Precondition: a != 0
     20 
     21 si_int __ctzdi2(di_int a);
     22 
     23 int test__ctzdi2(di_int a, si_int expected)
     24 {
     25     si_int x = __ctzdi2(a);
     26     if (x != expected)
     27         printf("error in __ctzdi2(0x%llX) = %d, expected %d\n", a, x, expected);
     28     return x != expected;
     29 }
     30 
     31 char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
     32 
     33 int main()
     34 {
     35 //    if (test__ctzdi2(0x00000000, N))  // undefined
     36 //        return 1;
     37     if (test__ctzdi2(0x00000001, 0))
     38         return 1;
     39     if (test__ctzdi2(0x00000002, 1))
     40         return 1;
     41     if (test__ctzdi2(0x00000003, 0))
     42         return 1;
     43     if (test__ctzdi2(0x00000004, 2))
     44         return 1;
     45     if (test__ctzdi2(0x00000005, 0))
     46         return 1;
     47     if (test__ctzdi2(0x0000000A, 1))
     48         return 1;
     49     if (test__ctzdi2(0x10000000, 28))
     50         return 1;
     51     if (test__ctzdi2(0x20000000, 29))
     52         return 1;
     53     if (test__ctzdi2(0x60000000, 29))
     54         return 1;
     55     if (test__ctzdi2(0x80000000uLL, 31))
     56         return 1;
     57     if (test__ctzdi2(0x0000050000000000uLL, 40))
     58         return 1;
     59     if (test__ctzdi2(0x0200080000000000uLL, 43))
     60         return 1;
     61     if (test__ctzdi2(0x7200000000000000uLL, 57))
     62         return 1;
     63     if (test__ctzdi2(0x8000000000000000uLL, 63))
     64         return 1;
     65 
     66    return 0;
     67 }
     68