diff --git a/llvm/lib/Support/KnownBits.cpp b/llvm/lib/Support/KnownBits.cpp index 1a5f1ad4cf03..13d79a389fd6 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 457b7c8a5af1..1607ddfdec50 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.