[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp

Reid Spencer reid at x10sys.com
Fri Mar 2 12:52:58 PST 2007



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

gptest.cpp updated: 1.9 -> 1.10
---
Log message:

Hack around pari/gp's inability to do an arithmetic shift right.


---
Diffs of the changes:  (+11 -13)

 gptest.cpp |   24 +++++++++++-------------
 1 files changed, 11 insertions(+), 13 deletions(-)


Index: llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp
diff -u llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.9 llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.10
--- llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp:1.9	Thu Mar  1 22:56:56 2007
+++ llvm-test/SingleSource/UnitTests/Integer/APInt/gptest.cpp	Fri Mar  2 14:52:41 2007
@@ -265,22 +265,20 @@
       printf(" u>> %d = %s (not %s)\n", i, gpresult.c_str(), apresult.c_str());
       fflush(stdout);
     }
+    cmd = "shift(" + v1.toString(10,false) + ",-" + utostr(i) + ")";
     if (v1.isNegative()) {
-      cmd = "shift(" + v1.toString(10,true) + ",-" + utostr(i-1) + ")\n";
-      R1 = v1.ashr(i-1);
-      apresult = R1.toString(10,true);
-    } else {
-      cmd = "shift(" + v1.toString(10,false) + ",-" + utostr(i) + ")\n";
-      R1 = v1.ashr(i);
-      apresult = R1.toString(10,false);
-    }
+      APInt hiMask(32, -1ULL);
+      hiMask.sextOrTrunc(v1.getBitWidth());
+      hiMask = hiMask.shl(v1.getBitWidth()-i);
+      cmd = "bitor(" + cmd + "," + hiMask.toString(10,false) + ")";
+    }
+    cmd += "\n";
+    R1 = v1.ashr(i);
+    apresult = R1.toString(10,false);
     gpresult = getResult(cmd);
     if (gpresult != apresult) {
-      if (v1.isNegative())
-        print(v1, true);
-      else
-        print(v1, false);
-      printf(" s>> %d = %s (not %s)\n", i, gpresult.c_str(), apresult.c_str());
+      print(v1, false);
+      printf(" s>> %d = %s (not %s) cmd=%s\n", i, gpresult.c_str(), apresult.c_str(), cmd.c_str());
       fflush(stdout);
     }
   }






More information about the llvm-commits mailing list