summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/APIntTest.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2019-07-02 13:21:17 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2019-07-02 13:21:17 +0000
commit1a5ebe1fb1cededdcbb009d973c515ecc4c79178 (patch)
tree01c763e17045a46f06510854f24c95b1622d13dd /llvm/unittests/ADT/APIntTest.cpp
parentca4e80182e38e844ba6342847c61a878e5689789 (diff)
downloadbcm5719-llvm-1a5ebe1fb1cededdcbb009d973c515ecc4c79178.tar.gz
bcm5719-llvm-1a5ebe1fb1cededdcbb009d973c515ecc4c79178.zip
[APIntTest] multiplicativeInverse(): clarify test
Clarify that multiplicative inverse exists for all odd numbers, and does not exist for all even numbers (including 0). llvm-svn: 364920
Diffstat (limited to 'llvm/unittests/ADT/APIntTest.cpp')
-rw-r--r--llvm/unittests/ADT/APIntTest.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp
index 64560669342..4ab79e4b32f 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -2527,10 +2527,13 @@ TEST(APIntTest, MultiplicativeInverseExaustive) {
.multiplicativeInverse(APInt::getSignedMinValue(BitWidth + 1))
.trunc(BitWidth);
APInt One = V * MulInv;
- EXPECT_TRUE(MulInv.isNullValue() || One.isOneValue())
- << " bitwidth = " << BitWidth << ", value = " << Value
- << ", computed multiplicative inverse = " << MulInv
- << ", value * multiplicative inverse = " << One << " (should be 1)";
+ if (!V.isNullValue() && V.countTrailingZeros() == 0) {
+ // Multiplicative inverse exists for all odd numbers.
+ EXPECT_TRUE(One.isOneValue());
+ } else {
+ // Multiplicative inverse does not exist for even numbers (and 0).
+ EXPECT_TRUE(MulInv.isNullValue());
+ }
}
}
}
OpenPOWER on IntegriCloud