Commit ee939fa0 by Alan Mishchenko

Improvements to the truth table computations.

parent d8e84ce6
...@@ -1004,8 +1004,6 @@ static inline int Abc_TtCountOnesSlow( word t ) ...@@ -1004,8 +1004,6 @@ static inline int Abc_TtCountOnesSlow( word t )
} }
static inline int Abc_TtCountOnes( word x ) static inline int Abc_TtCountOnes( word x )
{ {
if ( x == 0 )
return 0;
x = x - ((x >> 1) & 0x5555555555555555); x = x - ((x >> 1) & 0x5555555555555555);
x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333); x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333);
x = (x + (x >> 4)) & 0x0F0F0F0F0F0F0F0F; x = (x + (x >> 4)) & 0x0F0F0F0F0F0F0F0F;
...@@ -1031,17 +1029,20 @@ static inline int Abc_TtCountOnesInTruth( word * pTruth, int nVars ) ...@@ -1031,17 +1029,20 @@ static inline int Abc_TtCountOnesInTruth( word * pTruth, int nVars )
int nWords = Abc_TtWordNum( nVars ); int nWords = Abc_TtWordNum( nVars );
int k, Counter = 0; int k, Counter = 0;
for ( k = 0; k < nWords; k++ ) for ( k = 0; k < nWords; k++ )
Counter += Abc_TtCountOnes( pTruth[k] ); if ( pTruth[k] )
Counter += Abc_TtCountOnes( pTruth[k] );
return Counter; return Counter;
} }
static inline void Abc_TtCountOnesInCofs( word * pTruth, int nVars, int * pStore ) static inline void Abc_TtCountOnesInCofs( word * pTruth, int nVars, int * pStore )
{ {
word Temp;
int i, k, Counter, nWords; int i, k, Counter, nWords;
memset( pStore, 0, sizeof(int) * nVars ); memset( pStore, 0, sizeof(int) * nVars );
if ( nVars <= 6 ) if ( nVars <= 6 )
{ {
for ( i = 0; i < nVars; i++ ) 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; return;
} }
assert( nVars > 6 ); assert( nVars > 6 );
...@@ -1050,17 +1051,25 @@ static inline void Abc_TtCountOnesInCofs( word * pTruth, int nVars, int * pStore ...@@ -1050,17 +1051,25 @@ static inline void Abc_TtCountOnesInCofs( word * pTruth, int nVars, int * pStore
{ {
// count 1's for the first six variables // count 1's for the first six variables
for ( i = 0; i < 6; i++ ) 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 // count 1's for all other variables
Counter = Abc_TtCountOnes( pTruth[k] ); if ( pTruth[k] )
for ( i = 6; i < nVars; i++ ) {
if ( (k & (1 << (i-6))) == 0 ) Counter = Abc_TtCountOnes( pTruth[k] );
pStore[i] += Counter; for ( i = 6; i < nVars; i++ )
if ( (k & (1 << (i-6))) == 0 )
pStore[i] += Counter;
}
k++;
// count 1's for all other variables // count 1's for all other variables
Counter = Abc_TtCountOnes( pTruth[++k] ); if ( pTruth[k] )
for ( i = 6; i < nVars; i++ ) {
if ( (k & (1 << (i-6))) == 0 ) Counter = Abc_TtCountOnes( pTruth[k] );
pStore[i] += Counter; 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 ) static inline void Abc_TtCountOnesInCofsSlow( word * pTruth, int nVars, int * pStore )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment