Remove unused files: This is the old induction varaible cannonicalization
[oota-llvm.git] / tools / tests / testPow2.cpp
1 /* -*-c++-*- */
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include "llvm/Support/MathExtras.h"
6
7 inline void
8 testPow(int C, bool isPow)
9 {
10   unsigned pow = 0;
11   bool testIsPow = IsPowerOf2(C, pow);
12   if (isPow != testIsPow)
13     printf("ERROR: IsPowerOf2() says \t%d %s a power of 2 = %d\n",
14            C, (isPow? "IS" : "IS NOT"), pow);
15
16 #undef PRINT_CORRECT_RESULTS
17 #ifdef PRINT_CORRECT_RESULTS
18   else
19     printf("CORRECT: IsPowerOf2() says \t%d %s a power of 2 = %d\n",
20            C, (isPow? "IS" : "IS NOT"), pow);
21 #endif PRINT_CORRECT_RESULTS
22 }
23
24 int
25 main(int argc, char** argv)
26 {
27   unsigned L = (argc > 1)? atoi(argv[1]) : 16;
28   unsigned C = 1;
29   
30   testPow(0, false);
31   
32   for (unsigned i = 1; i < L; i++, C = C << 1)
33     {
34       testPow(C, true);
35       testPow(-C, true);
36       for (unsigned j = C+1; j < (C << 1); j++)
37         {
38           testPow(j, false);
39           testPow(-j, false);
40         }
41     }
42   
43   return 0;
44 }
45
46