[llvm] r235536 - Another test to exercise APInt divide step D6.

Yaron Keren yaron.keren at gmail.com
Wed Apr 22 11:50:00 PDT 2015


Author: yrnkrn
Date: Wed Apr 22 13:49:59 2015
New Revision: 235536

URL: http://llvm.org/viewvc/llvm-project?rev=235536&view=rev
Log:
Another test to exercise APInt divide step D6.

This is divrem_big7 since divrem_big6 is used in Pawel upcoming patch.


Modified:
    llvm/trunk/unittests/ADT/APIntTest.cpp

Modified: llvm/trunk/unittests/ADT/APIntTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/APIntTest.cpp?rev=235536&r1=235535&r2=235536&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/APIntTest.cpp (original)
+++ llvm/trunk/unittests/ADT/APIntTest.cpp Wed Apr 22 13:49:59 2015
@@ -409,6 +409,19 @@ TEST(APIntTest, divrem_big5) {
   EXPECT_EQ(r, c);
 }
 
+TEST(APIntTest, divrem_big7) {
+  // Yet another test for KnuthDiv rare step D6.
+  APInt a{224, "800000008000000200000005", 16};
+  APInt b{224, "fffffffd", 16};
+  APInt c{224, "80000000800000010000000f", 16};
+
+  auto p = a * b + c;
+  auto q = p.udiv(a);
+  auto r = p.urem(a);
+  EXPECT_EQ(q, b);
+  EXPECT_EQ(r, c);
+}
+
 TEST(APIntTest, fromString) {
   EXPECT_EQ(APInt(32, 0), APInt(32,   "0", 2));
   EXPECT_EQ(APInt(32, 1), APInt(32,   "1", 2));





More information about the llvm-commits mailing list