Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/ir/constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ void AndedConstraintSet::approximateAnd(const Constraint& c) {
return;
}

if (proves(c) == False) {
auto result = proves(c);
if (result == True) {
// We already prove c to be true, so it adds nothing.
// TODO: we could also see if c proves us true, and replace things we
// already have with c when possible
return;
} else if (result == False) {
// We are now a contradiction.
isContradiction = true;
return;
Expand Down
12 changes: 12 additions & 0 deletions test/gtest/constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,17 @@ TEST(ConstraintTest, TestMaxCapacity) {
EXPECT_EQ(s.proves(not40), Unknown);
}

TEST(ConstraintTest, TestDeduplication) {
Constraint eq10{Eq, {Literal(int32_t(10))}};

AndedConstraintSet s;
EXPECT_EQ(s.size(), 0);
s.set(eq10);
EXPECT_EQ(s.size(), 1);
// The size does not increase when we add eq10 again.
s.approximateAnd(eq10);
EXPECT_EQ(s.size(), 1);
}

// TODO: test an approximateOr of { x = 10 } and { x >= 0 }, once we support
// inequalities
Loading