Skip to content

Commit 5f5de7a

Browse files
authored
Merge pull request #559 from calewis/fast_reverse_level
Avoid pointer chasing for pFanout->Id when we already have it in `Aig_ManUpdateReverseLevel`
2 parents c6e8823 + 38fbab5 commit 5f5de7a

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/aig/aig/aig.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ static inline int Aig_ObjFanoutNext( Aig_Man_t * p, int iFan ) { assert(iF
428428
for ( assert(p->pFanData), i = 0; (i < (int)(pObj)->nRefs) && \
429429
(((iFan) = i? Aig_ObjFanoutNext(p, iFan) : Aig_ObjFanout0Int(p, pObj->Id)), 1) && \
430430
(((pFanout) = Aig_ManObj(p, iFan>>1)), 1); i++ )
431+
#define Aig_ObjForEachFanoutId( p, pObj, FanId, iFan, i ) \
432+
for ( assert(p->pFanData), i = 0; (i < (int)(pObj)->nRefs) && \
433+
(((iFan) = i? Aig_ObjFanoutNext(p, iFan) : Aig_ObjFanout0Int(p, pObj->Id)), 1) && \
434+
(((FanId) = (iFan >> 1)), 1); i++ )
431435

432436

433437
////////////////////////////////////////////////////////////////////////

src/aig/aig/aigTiming.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,10 @@ int Aig_ObjRequiredLevel( Aig_Man_t * p, Aig_Obj_t * pObj )
116116
***********************************************************************/
117117
int Aig_ObjReverseLevelNew( Aig_Man_t * p, Aig_Obj_t * pObj )
118118
{
119-
Aig_Obj_t * pFanout;
120-
int i, iFanout = -1, LevelCur, Level = 0;
121-
Aig_ObjForEachFanout( p, pObj, pFanout, iFanout, i )
119+
int i, iFanout = -1, FanoutId, LevelCur, Level = 0;
120+
Aig_ObjForEachFanoutId( p, pObj, FanoutId, iFanout, i )
122121
{
123-
LevelCur = Aig_ObjReverseLevel( p, pFanout );
122+
LevelCur = Vec_IntGetEntry( p->vLevelR, FanoutId );
124123
Level = Abc_MaxInt( Level, LevelCur );
125124
}
126125
return Level + 1;
@@ -250,6 +249,8 @@ void Aig_ManUpdateReverseLevel( Aig_Man_t * p, Aig_Obj_t * pObjNew )
250249
int LevelOld, LevFanin, Lev, k;
251250
assert( p->vLevelR != NULL );
252251
assert( Aig_ObjIsNode(pObjNew) );
252+
// ensure reverse levels array is large enough for all objects
253+
Vec_IntFillExtra( p->vLevelR, Aig_ManObjNumMax(p), 0 );
253254
// allocate level if needed
254255
if ( p->vLevels == NULL )
255256
p->vLevels = Vec_VecAlloc( Aig_ManLevels(p) + 8 );

0 commit comments

Comments
 (0)