Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Spot
Spot
Commits
fb3edb47
Commit
fb3edb47
authored
Jun 10, 2011
by
Alexandre Duret-Lutz
Browse files
[buddy] * src/bddop.c (apply_rec, appquant_rec): Improve caching by
reordering operands of commutative operators.
parent
c42d55e6
Changes
2
Show whitespace changes
Inline
Side-by-side
buddy/ChangeLog
View file @
fb3edb47
2011-06-10 Alexandre Duret-Lutz <adl@lrde.epita.fr>
* src/bddop.c (apply_rec, appquant_rec): Improve caching by
reordering operands of commutative operators.
2011-06-09 Alexandre Duret-Lutz <adl@lrde.epita.fr>
2011-06-09 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Remove some valgrind warnings about uninitialized memory when
Remove some valgrind warnings about uninitialized memory when
...
...
buddy/src/bddop.c
View file @
fb3edb47
...
@@ -570,36 +570,76 @@ static BDD apply_rec(BDD l, BDD r)
...
@@ -570,36 +570,76 @@ static BDD apply_rec(BDD l, BDD r)
case
bddop_and
:
case
bddop_and
:
if
(
l
==
r
)
if
(
l
==
r
)
return
l
;
return
l
;
if
(
ISZERO
(
l
)
||
ISZERO
(
r
))
/* The operation is commutative, so lets
order the arguments to favor cache hits. */
if
(
l
>
r
)
{
BDD
tmp
=
l
;
l
=
r
;
r
=
tmp
;
}
if
(
ISZERO
(
l
)
/* || ISZERO(r) */
)
return
0
;
return
0
;
if
(
ISONE
(
l
))
if
(
ISONE
(
l
))
return
r
;
return
r
;
if
(
ISONE
(
r
))
/*
if (ISONE(r))
return
l
;
return l;
*/
break
;
break
;
case
bddop_or
:
case
bddop_or
:
if
(
l
==
r
)
if
(
l
==
r
)
return
l
;
return
l
;
/* The operation is commutative, so lets
order the arguments to favor cache hits. */
if
(
l
>
r
)
{
BDD
tmp
=
l
;
l
=
r
;
r
=
tmp
;
}
if
(
ISONE
(
l
)
||
ISONE
(
r
))
if
(
ISONE
(
l
)
||
ISONE
(
r
))
return
1
;
return
1
;
if
(
ISZERO
(
l
))
if
(
ISZERO
(
l
))
return
r
;
return
r
;
if
(
ISZERO
(
r
))
/*
if (ISZERO(r))
return
l
;
return l;
*/
break
;
break
;
case
bddop_xor
:
case
bddop_xor
:
if
(
l
==
r
)
if
(
l
==
r
)
return
0
;
return
0
;
/* The operation is commutative, so lets
order the arguments to favor cache hits. */
if
(
l
>
r
)
{
BDD
tmp
=
l
;
l
=
r
;
r
=
tmp
;
}
if
(
ISZERO
(
l
))
if
(
ISZERO
(
l
))
return
r
;
return
r
;
if
(
ISZERO
(
r
))
/*
if (ISZERO(r))
return
l
;
return l;
*/
break
;
break
;
case
bddop_nand
:
case
bddop_nand
:
if
(
ISZERO
(
l
)
||
ISZERO
(
r
))
/* The operation is commutative, so lets
order the arguments to favor cache hits. */
if
(
l
>
r
)
{
BDD
tmp
=
l
;
l
=
r
;
r
=
tmp
;
}
if
(
ISZERO
(
l
)
/* || ISZERO(r) */
)
return
1
;
return
1
;
break
;
break
;
case
bddop_nor
:
case
bddop_nor
:
/* The operation is commutative, so lets
order the arguments to favor cache hits. */
if
(
l
>
r
)
{
BDD
tmp
=
l
;
l
=
r
;
r
=
tmp
;
}
if
(
ISONE
(
l
)
||
ISONE
(
r
))
if
(
ISONE
(
l
)
||
ISONE
(
r
))
return
0
;
return
0
;
break
;
break
;
...
@@ -611,6 +651,16 @@ static BDD apply_rec(BDD l, BDD r)
...
@@ -611,6 +651,16 @@ static BDD apply_rec(BDD l, BDD r)
if
(
ISONE
(
r
))
if
(
ISONE
(
r
))
return
1
;
return
1
;
break
;
break
;
case
bddop_biimp
:
/* The operation is commutative, so lets
order the arguments to favor cache hits. */
if
(
l
>
r
)
{
BDD
tmp
=
l
;
l
=
r
;
r
=
tmp
;
}
break
;
}
}
if
(
ISCONST
(
l
)
&&
ISCONST
(
r
))
if
(
ISCONST
(
l
)
&&
ISCONST
(
r
))
...
@@ -2083,40 +2133,90 @@ static int appquant_rec(int l, int r)
...
@@ -2083,40 +2133,90 @@ static int appquant_rec(int l, int r)
switch
(
appexop
)
switch
(
appexop
)
{
{
case
bddop_and
:
case
bddop_and
:
if
(
l
==
0
||
r
==
0
)
/* The operation is commutative, so lets
order the arguments to favor cache hits. */
if
(
l
>
r
)
{
BDD
tmp
=
l
;
l
=
r
;
r
=
tmp
;
}
if
(
l
==
0
/* || r == 0 */
)
return
0
;
return
0
;
if
(
l
==
r
)
if
(
l
==
r
)
return
quant_rec
(
l
);
return
quant_rec
(
l
);
if
(
l
==
1
)
if
(
l
==
1
)
return
quant_rec
(
r
);
return
quant_rec
(
r
);
if
(
r
==
1
)
/*
if (r == 1)
return
quant_rec
(
l
);
return quant_rec(l);
*/
break
;
break
;
case
bddop_or
:
case
bddop_or
:
if
(
l
==
1
||
r
==
1
)
if
(
l
==
1
||
r
==
1
)
return
1
;
return
1
;
if
(
l
==
r
)
if
(
l
==
r
)
return
quant_rec
(
l
);
return
quant_rec
(
l
);
/* The operation is commutative, so lets
order the arguments to favor cache hits. */
if
(
l
>
r
)
{
BDD
tmp
=
l
;
l
=
r
;
r
=
tmp
;
}
if
(
l
==
0
)
if
(
l
==
0
)
return
quant_rec
(
r
);
return
quant_rec
(
r
);
if
(
r
==
0
)
/*
if (r == 0)
return
quant_rec
(
l
);
return quant_rec(l);
*/
break
;
break
;
case
bddop_xor
:
case
bddop_xor
:
if
(
l
==
r
)
if
(
l
==
r
)
return
0
;
return
0
;
/* The operation is commutative, so lets
order the arguments to favor cache hits. */
if
(
l
>
r
)
{
BDD
tmp
=
l
;
l
=
r
;
r
=
tmp
;
}
if
(
l
==
0
)
if
(
l
==
0
)
return
quant_rec
(
r
);
return
quant_rec
(
r
);
if
(
r
==
0
)
/*
if (r == 0)
return
quant_rec
(
l
);
return quant_rec(l);
*/
break
;
break
;
case
bddop_nand
:
case
bddop_nand
:
if
(
l
==
0
||
r
==
0
)
/* The operation is commutative, so lets
order the arguments to favor cache hits. */
if
(
l
>
r
)
{
BDD
tmp
=
l
;
l
=
r
;
r
=
tmp
;
}
if
(
l
==
0
/* || r == 0 */
)
return
1
;
return
1
;
break
;
break
;
case
bddop_nor
:
case
bddop_nor
:
if
(
l
==
1
||
r
==
1
)
if
(
l
==
1
||
r
==
1
)
return
0
;
return
0
;
/* The operation is commutative, so lets
order the arguments to favor cache hits. */
if
(
l
>
r
)
{
BDD
tmp
=
l
;
l
=
r
;
r
=
tmp
;
}
break
;
case
bddop_biimp
:
/* The operation is commutative, so lets
order the arguments to favor cache hits. */
if
(
l
>
r
)
{
BDD
tmp
=
l
;
l
=
r
;
r
=
tmp
;
}
break
;
break
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment