[KnownBits] Check for conflict-freedom in exhaustive tests

And make sure udiv() Exact does not produce conflicts.
This commit is contained in:
Nikita Popov 2023-05-24 10:32:20 +02:00
parent 577b163277
commit d4bfc144ea
2 changed files with 4 additions and 0 deletions

View File

@ -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;

View File

@ -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.