diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2012-10-31 01:33:13 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2012-10-31 01:33:13 -0700 |
commit | ee939fa0ddb2620084d1703fee932e9c9630834d (patch) | |
tree | cc58fc9fff8e4e21696f249d3c77cbe80831c9fd | |
parent | d8e84ce6662ecf1706dfada3724e6b1e93e51918 (diff) | |
download | abc-ee939fa0ddb2620084d1703fee932e9c9630834d.tar.gz abc-ee939fa0ddb2620084d1703fee932e9c9630834d.tar.bz2 abc-ee939fa0ddb2620084d1703fee932e9c9630834d.zip |
Improvements to the truth table computations.
-rw-r--r-- | src/misc/util/utilTruth.h | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/misc/util/utilTruth.h b/src/misc/util/utilTruth.h index 4c4ced4c..443ff061 100644 --- a/src/misc/util/utilTruth.h +++ b/src/misc/util/utilTruth.h @@ -1004,8 +1004,6 @@ static inline int Abc_TtCountOnesSlow( word t ) } static inline int Abc_TtCountOnes( word x ) { - if ( x == 0 ) - return 0; x = x - ((x >> 1) & 0x5555555555555555); x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333); x = (x + (x >> 4)) & 0x0F0F0F0F0F0F0F0F; @@ -1031,17 +1029,20 @@ static inline int Abc_TtCountOnesInTruth( word * pTruth, int nVars ) int nWords = Abc_TtWordNum( nVars ); int k, Counter = 0; for ( k = 0; k < nWords; k++ ) - Counter += Abc_TtCountOnes( pTruth[k] ); + if ( pTruth[k] ) + Counter += Abc_TtCountOnes( pTruth[k] ); return Counter; } static inline void Abc_TtCountOnesInCofs( word * pTruth, int nVars, int * pStore ) { + word Temp; int i, k, Counter, nWords; memset( pStore, 0, sizeof(int) * nVars ); if ( nVars <= 6 ) { for ( i = 0; i < nVars; i++ ) - pStore[i] = Abc_TtCountOnes( pTruth[0] & s_Truths6Neg[i] ); + if ( pTruth[0] & s_Truths6Neg[i] ) + pStore[i] = Abc_TtCountOnes( pTruth[0] & s_Truths6Neg[i] ); return; } assert( nVars > 6 ); @@ -1050,17 +1051,25 @@ static inline void Abc_TtCountOnesInCofs( word * pTruth, int nVars, int * pStore { // count 1's for the first six variables for ( i = 0; i < 6; i++ ) - pStore[i] += Abc_TtCountOnes( (pTruth[k] & s_Truths6Neg[i]) | ((pTruth[k+1] & s_Truths6Neg[i]) << (1 << i)) ); + if ( (Temp = (pTruth[k] & s_Truths6Neg[i]) | ((pTruth[k+1] & s_Truths6Neg[i]) << (1 << i))) ) + pStore[i] += Abc_TtCountOnes( Temp ); // count 1's for all other variables - Counter = Abc_TtCountOnes( pTruth[k] ); - for ( i = 6; i < nVars; i++ ) - if ( (k & (1 << (i-6))) == 0 ) - pStore[i] += Counter; + if ( pTruth[k] ) + { + Counter = Abc_TtCountOnes( pTruth[k] ); + for ( i = 6; i < nVars; i++ ) + if ( (k & (1 << (i-6))) == 0 ) + pStore[i] += Counter; + } + k++; // count 1's for all other variables - Counter = Abc_TtCountOnes( pTruth[++k] ); - for ( i = 6; i < nVars; i++ ) - if ( (k & (1 << (i-6))) == 0 ) - pStore[i] += Counter; + if ( pTruth[k] ) + { + Counter = Abc_TtCountOnes( pTruth[k] ); + for ( i = 6; i < nVars; i++ ) + if ( (k & (1 << (i-6))) == 0 ) + pStore[i] += Counter; + } } } static inline void Abc_TtCountOnesInCofsSlow( word * pTruth, int nVars, int * pStore ) |