Skip to content

Commit

Permalink
Fix: Unique pairs for commutative operators (apply cache)
Browse files Browse the repository at this point in the history
The bug did not lead to incorrect results but has probably affected
performance in a negative way.

Thanks @TarVK!
  • Loading branch information
nhusung committed Apr 20, 2024
1 parent 04f4cc7 commit 8b121d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/oxidd-rules-bdd/src/simple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ fn terminal_bin<'a, M: Manager<Terminal = BDDTerminal>, const OP: u8>(
match (m.get_node(f), m.get_node(g)) {
// Unique representation of {f, g} for commutative functions
(Inner(_), Inner(_)) if f > g => Binary(BDDOp::And, g.borrowed(), f.borrowed()),
(Inner(_), Inner(_)) => Binary(BDDOp::And, g.borrowed(), f.borrowed()),
(Inner(_), Inner(_)) => Binary(BDDOp::And, f.borrowed(), g.borrowed()),
(Terminal(t), _) | (_, Terminal(t)) if *t.borrow() == False => {
Done(m.get_terminal(False).unwrap())
}
Expand All @@ -247,7 +247,7 @@ fn terminal_bin<'a, M: Manager<Terminal = BDDTerminal>, const OP: u8>(
}
match (m.get_node(f), m.get_node(g)) {
(Inner(_), Inner(_)) if f > g => Binary(BDDOp::Or, g.borrowed(), f.borrowed()),
(Inner(_), Inner(_)) => Binary(BDDOp::Or, g.borrowed(), f.borrowed()),
(Inner(_), Inner(_)) => Binary(BDDOp::Or, f.borrowed(), g.borrowed()),
(Terminal(t), _) | (_, Terminal(t)) if *t.borrow() == True => {
Done(m.get_terminal(True).unwrap())
}
Expand All @@ -260,7 +260,7 @@ fn terminal_bin<'a, M: Manager<Terminal = BDDTerminal>, const OP: u8>(
}
match (m.get_node(f), m.get_node(g)) {
(Inner(_), Inner(_)) if f > g => Binary(BDDOp::Nand, g.borrowed(), f.borrowed()),
(Inner(_), Inner(_)) => Binary(BDDOp::Nand, g.borrowed(), f.borrowed()),
(Inner(_), Inner(_)) => Binary(BDDOp::Nand, f.borrowed(), g.borrowed()),
(Terminal(t), _) | (_, Terminal(t)) if *t.borrow() == False => {
Done(m.get_terminal(True).unwrap())
}
Expand All @@ -273,7 +273,7 @@ fn terminal_bin<'a, M: Manager<Terminal = BDDTerminal>, const OP: u8>(
}
match (m.get_node(f), m.get_node(g)) {
(Inner(_), Inner(_)) if f > g => Binary(BDDOp::Nor, g.borrowed(), f.borrowed()),
(Inner(_), Inner(_)) => Binary(BDDOp::Nor, g.borrowed(), f.borrowed()),
(Inner(_), Inner(_)) => Binary(BDDOp::Nor, f.borrowed(), g.borrowed()),
(Terminal(t), _) | (_, Terminal(t)) if *t.borrow() == True => {
Done(m.get_terminal(False).unwrap())
}
Expand Down

0 comments on commit 8b121d1

Please sign in to comment.