diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2018-12-12 10:47:53 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2018-12-12 10:47:53 -0800 |
commit | 2f88284d7b5dd2fc7e9d1141d8818a6349f15194 (patch) | |
tree | 955a3f980ee1d6e34d1966017d9cd160e8ccccc7 | |
parent | d071e0261630142b97c50ffc7740375c6b671da7 (diff) | |
download | abc-2f88284d7b5dd2fc7e9d1141d8818a6349f15194.tar.gz abc-2f88284d7b5dd2fc7e9d1141d8818a6349f15194.tar.bz2 abc-2f88284d7b5dd2fc7e9d1141d8818a6349f15194.zip |
Fixing float overflow during edge-flow computation in 'if' mapper.
-rw-r--r-- | src/map/if/ifCut.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/map/if/ifCut.c b/src/map/if/ifCut.c index 47127fda..9d884e75 100644 --- a/src/map/if/ifCut.c +++ b/src/map/if/ifCut.c @@ -953,18 +953,22 @@ float If_CutAreaFlow( If_Man_t * p, If_Cut_t * pCut ) float If_CutEdgeFlow( If_Man_t * p, If_Cut_t * pCut ) { If_Obj_t * pLeaf; - float Flow; + float Flow, AddOn; int i; Flow = pCut->nLeaves; If_CutForEachLeaf( p, pCut, pLeaf, i ) { if ( pLeaf->nRefs == 0 || If_ObjIsConst1(pLeaf) ) - Flow += If_ObjCutBest(pLeaf)->Edge; + AddOn = If_ObjCutBest(pLeaf)->Edge; else { assert( pLeaf->EstRefs > p->fEpsilon ); - Flow += If_ObjCutBest(pLeaf)->Edge / pLeaf->EstRefs; + AddOn = If_ObjCutBest(pLeaf)->Edge / pLeaf->EstRefs; } + if ( Flow >= (float)1e32 || AddOn >= (float)1e32 ) + Flow = (float)1e32; + else + Flow += AddOn; } return Flow; } |