[llvm] d4bfc14 - [KnownBits] Check for conflict-freedom in exhaustive tests
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 24 01:34:53 PDT 2023
Author: Nikita Popov
Date: 2023-05-24T10:34:44+02:00
New Revision: d4bfc144eaa6e34eafaab1e8574421ebd2bb78ed
URL: https://github.com/llvm/llvm-project/commit/d4bfc144eaa6e34eafaab1e8574421ebd2bb78ed
DIFF: https://github.com/llvm/llvm-project/commit/d4bfc144eaa6e34eafaab1e8574421ebd2bb78ed.diff
LOG: [KnownBits] Check for conflict-freedom in exhaustive tests
And make sure udiv() Exact does not produce conflicts.
Added:
Modified:
llvm/lib/Support/KnownBits.cpp
llvm/unittests/Support/KnownBitsTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/KnownBits.cpp b/llvm/lib/Support/KnownBits.cpp
index 1a5f1ad4cf03e..13d79a389fd6a 100644
--- a/llvm/lib/Support/KnownBits.cpp
+++ b/llvm/lib/Support/KnownBits.cpp
@@ -839,6 +839,8 @@ KnownBits KnownBits::udiv(const KnownBits &LHS, const KnownBits &RHS,
Known.Zero.setBit(0);
// Odd / Even -> impossible
// Even / Even -> unknown
+ if (Known.hasConflict())
+ Known.setAllZero();
}
return Known;
diff --git a/llvm/unittests/Support/KnownBitsTest.cpp b/llvm/unittests/Support/KnownBitsTest.cpp
index 457b7c8a5af14..1607ddfdec502 100644
--- a/llvm/unittests/Support/KnownBitsTest.cpp
+++ b/llvm/unittests/Support/KnownBitsTest.cpp
@@ -79,6 +79,7 @@ static void testUnaryOpExhaustive(
}
});
+ EXPECT_TRUE(!Computed.hasConflict());
EXPECT_TRUE(isCorrect(Exact, Computed, Known));
// We generally don't want to return conflicting known bits, even if it is
// legal for always poison results.
@@ -110,6 +111,7 @@ static void testBinaryOpExhaustive(
});
});
+ EXPECT_TRUE(!Computed.hasConflict());
EXPECT_TRUE(isCorrect(Exact, Computed, {Known1, Known2}));
// We generally don't want to return conflicting known bits, even if it is
// legal for always poison results.
More information about the llvm-commits
mailing list