Skip to content

Conversation

@EPTansuo
Copy link

This PR fixes a reproducible assertion failure in Gia_ManChoiceLevel() when running &if on AIGs containing choices introduced by dch -f (reported in #466).

##Root Cause
dch -f can introduce choices that leave some AND nodes dangling (not reachable from CO/CI). Gia_ManChoiceLevel only computes levels by traversing CO/CI, so dangling ANDs keep level 0 and trip the assert.

Fix

Compute levels for any AND nodes that were not visited by the CO/CI traversal before the final assertion, so all ANDs have a valid level.

Test

abc -c "ra i10.aig; strash; dch -f; &get; &if -K 6;"

@wjrforcyber
Copy link
Contributor

Emmm, the temporary fix LGTM but the reason doesn't look correct.

dch -f can introduce choices that leave some AND nodes dangling (not reachable from CO/CI). Gia_ManChoiceLevel only computes levels by traversing CO/CI, so dangling ANDs keep level 0 and trip the assert.

In the implementation of Gia_ManChoiceLevel_rec which is called byGia_ManChoiceLevel:

abc/src/aig/gia/giaIf.c

Lines 801 to 807 in 291e0a2

// get the level of the nodes in the choice node
if ( (pNext = Gia_ObjSiblObj(p, Gia_ObjId(p, pObj))) )
{
Gia_ManChoiceLevel_rec( p, pNext );
if ( LevelMax < Gia_ObjLevel(p, pNext) )
LevelMax = Gia_ObjLevel(p, pNext);
}

These lines recursively calls the pNext on "siblings"(or "choice candidates", "dangling nodes") on original ANDs so all are calculated.
I don't have time recheck but I think it's something about &get since dch and &dch put choices in different structure, it has been modified several times, you could see that run a modified version of your flow

./abc -c "read_blif input.blif; strash; refactor; rewrite -z; &get; &dch -f; &ps; &if -K 4"

(which puts &dch in ABC9 space) everything's fine.

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.

2 participants