Skip to content

&sopb: fold x & !x when two cut leaves share a literal - #609

Open
gigeresk wants to merge 1 commit into
berkeley-abc:masterfrom
gigeresk:sopb-shared-leaf-literal
Open

gigeresk wants to merge 1 commit into
berkeley-abc:masterfrom
gigeresk:sopb-shared-leaf-literal

Conversation

@gigeresk

Copy link
Copy Markdown
Contributor

&sopb can abort with:

Assertion failed: (p->fGiaSimple || Abc_Lit2Var(iLit0) != Abc_Lit2Var(iLit1)), function Gia_ManAppendAnd, file gia.h, line 763.


To reproduce on current master:

./abc -c "&r test/sopb_shared_leaf.aig; &sopb -C 3"

Cause

The assert requires that the two inputs of a new AND come from different nodes.
Gia_ManBuildFromMiniInt() called Gia_ManAppendAnd() with x and !x, which are the same node.

Fix

In the unhashed (fHash=0) branch of Gia_ManBuildFromMiniInt(), call Gia_ManAppendAnd2() instead of Gia_ManAppendAnd(). Gia_ManAppendAnd2() returns 0 for x & !x, and also folds x & x and constant inputs, before calling Gia_ManAppendAnd(), so the assert can no longer fire.

Note that since Gia_ManAppendAnd2() already folds x & x, the separate iLit0 == iLit1 branch became redundant, so this change removes it.

Test

test/sopb_shared_leaf.aig is reduced from a case that triggered the assert and passes with this change.

Gia_ManFromIfAig() rebuilds the AIG without structural hashing. When a
mapped node's cut collapses to one of its own leaves, the node takes that
leaf's literal instead of a new one. A later cut can then have both as
leaves, and Gia_ManBuildFromMiniInt() asked Gia_ManAppendAnd() for an AND
of a literal and its complement, failing its same-variable assertion. Only
the x & x case was folded. &dsdb goes through the same code.

Use Gia_ManAppendAnd2(), which also folds x & !x and constant operands. It
differs from the old code only for those operands.

Add test/sopb_shared_leaf.{aig,sh}: an 89-node AIG on which &sopb -C 3
aborted. Run it in both POSIX workflows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant