From 123cdacd90168d4d8825630d58eb70d112368e16 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Tue, 2 Jul 2019 13:21:17 +0000 Subject: [PATCH] [APIntTest] multiplicativeInverse(): clarify test Clarify that multiplicative inverse exists for all odd numbers, and does not exist for all even numbers (including 0). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364920 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/ADT/APIntTest.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/unittests/ADT/APIntTest.cpp b/unittests/ADT/APIntTest.cpp index 64560669342..4ab79e4b32f 100644 --- a/unittests/ADT/APIntTest.cpp +++ b/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()); + } } } } -- 2.11.0