[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp bigint.cpp sign.cpp

Zhou Sheng zhousheng00 at gmail.com
Sun Feb 11 00:50:17 PST 2007



Changes in directory llvm-test/SingleSource/UnitTests/Integer/APInt:

arith.cpp updated: 1.2 -> 1.3
bigint.cpp updated: 1.2 -> 1.3
sign.cpp updated: 1.2 -> 1.3
---
Log message:

Updates these test cases as APInt class modifed.


---
Diffs of the changes:  (+19 -16)

 arith.cpp  |    8 ++++----
 bigint.cpp |    6 +++---
 sign.cpp   |   21 ++++++++++++---------
 3 files changed, 19 insertions(+), 16 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.2 llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.3
--- llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp:1.2	Mon Feb  5 21:02:16 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/arith.cpp	Sun Feb 11 02:49:48 2007
@@ -41,21 +41,21 @@
   temp = k.getValue();
   printf( "temp = %hd\n", temp);
   j *= 120;
-  l = j / k;
+  l = APIntOps::sdiv(j, k);
   temp = l.getValue();
   printf( "temp = %hd\n", temp);
   j *= (-176); // after truncation, the value should be -384
-  l = j / k;
+  l = APIntOps::sdiv(j, k);
   temp = l.getValue();
   printf( "temp = %hd\n", temp);
   l = 120;
   l = (j * l);
-  l %= 4;
+  l = APIntOps::urem(l, 4);
   temp = l.getValue();
   printf( "temp = %hd\n", temp);
   l = -217;
   l = (j * l);
-  l = l / (++i);
+  l = APIntOps::sdiv(l, (++i));
   temp = l.getValue();
   printf( "temp = %hd\n", temp);
   result = ++x;


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp:1.2 llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp:1.3
--- llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp:1.2	Mon Feb  5 21:02:16 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/bigint.cpp	Sun Feb 11 02:49:48 2007
@@ -31,7 +31,7 @@
     for ( ; ; ) {
       bool ssdm_tmp_1 = (i < bnd);
       if (!ssdm_tmp_1) break;
-      if (i % 2 == 0)
+      if (APIntOps::urem(i, 2) == 0)
         x = x + 1;
       else 
         y = y - x;
@@ -40,11 +40,11 @@
     }
   }
   result = x*y;
-  l_result = result % 0x37015; 
+  l_result = APIntOps::srem(result, 0x37015);
   rem = l_result.getValue();
   printf("rem = %lld\n", rem);
 
-  l_result = result % -198721;
+  l_result = APIntOps::srem(result, -198721);
   rem2 = l_result.getValue();
   printf("rem2 = %lld\n", rem2);
   return 0;


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp:1.2 llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp:1.3
--- llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp:1.2	Mon Feb  5 21:02:16 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/sign.cpp	Sun Feb 11 02:49:48 2007
@@ -19,7 +19,7 @@
 main ( int argc, char** argv)
 {
   int num, r;
-  APInt x(0, 24, true), y(0, 24, true), z(0, 24, true);
+  APInt x(0, 24), y(0, 24), z(0, 24);
   APInt ux(0, 24), uy(0, 24), uz(0, 24);
 
   r = rand();
@@ -30,10 +30,13 @@
   
   if (argc > 1)
     num = atoi(argv[1]);
+  else
+    num = 0;
 
   
   num = num - 0xdf5e75; //0x1000001
 
+  printf("num = %d\n", num);
   x = num;
   ux = num;
   printf("x = %d, ux = %u, y=%d, uy = %u\n", int(x.getValue()), 
@@ -44,20 +47,20 @@
   uz = ux * uy;
   printf("z=%d, uz=%u\n", int(z.getValue()), (unsigned int)uz.getValue());
 
-  z = x % 314;
-  uz = ux % 314;
+  z = APIntOps::srem(x, 314);
+  uz = APIntOps::urem(ux, 314);
   printf("z=%d, uz=%u\n", int(z.getValue()), (unsigned int)uz.getValue());
 
-  z = x / 314;
-  uz = ux / 314;
+  z = APIntOps::sdiv(x, 314);
+  uz = APIntOps::udiv(ux, 314);
   printf("z=%d, uz=%u\n", int(z.getValue()), (unsigned int)uz.getValue());
 
-  z = (x+0xf28) / 314;
-  uz = (ux + 0xf28) / 314;
+  z = APIntOps::sdiv((x+0xf28), 314);
+  uz = APIntOps::udiv((ux + 0xf28), 314);
   printf("z=%d, uz=%u\n", int(z.getValue()), (unsigned int)uz.getValue());
 
-  z = (x - 580) / 314;
-  uz = (((ux - 580)) / 314);
+  z = APIntOps::sdiv((x - 580), 314);
+  uz = APIntOps::udiv((ux - 580), 314);
   printf("z=%d, uz=%u\n", int(z.getValue()), (unsigned int)uz.getValue());
 
   return 0;






More information about the llvm-commits mailing list