[PPL-devel] [GIT] ppl/ppl(master): Improved set_union(const Bit_Row&, const Bit_Row&, Bit_Row&).
Roberto Bagnara
bagnara at cs.unipr.it
Mon Apr 20 16:25:09 CEST 2009
Module: ppl/ppl
Branch: master
Commit: 12dc53fb2a829b9ae88c49c5a5dd796df4cc8ced
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=12dc53fb2a829b9ae88c49c5a5dd796df4cc8ced
Author: Roberto Bagnara <bagnara at cs.unipr.it>
Date: Mon Apr 20 16:15:22 2009 +0200
Improved set_union(const Bit_Row&, const Bit_Row&, Bit_Row&).
Used the new Bit_Row set-union constructor wherever possible.
---
src/Bit_Row.cc | 2 --
src/Bit_Row.inlines.hh | 17 ++++++++++++++---
src/Polyhedron_nonpublic.cc | 15 ++++-----------
src/conversion.cc | 3 +--
4 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/src/Bit_Row.cc b/src/Bit_Row.cc
index e1d2e0f..4cece3a 100644
--- a/src/Bit_Row.cc
+++ b/src/Bit_Row.cc
@@ -28,8 +28,6 @@ site: http://www.cs.unipr.it/ppl/ . */
namespace PPL = Parma_Polyhedra_Library;
-#define PPL_BITS_PER_GMP_LIMB (PPL_SIZEOF_MP_LIMB_T*CHAR_BIT)
-
#if !PPL_HAVE_DECL_FFS || PPL_SIZEOF_MP_LIMB_T != PPL_SIZEOF_INT
unsigned int
PPL::Bit_Row::first_one(mp_limb_t w) {
diff --git a/src/Bit_Row.inlines.hh b/src/Bit_Row.inlines.hh
index 5321f41..c681c8a 100644
--- a/src/Bit_Row.inlines.hh
+++ b/src/Bit_Row.inlines.hh
@@ -33,6 +33,8 @@ site: http://www.cs.unipr.it/ppl/ . */
# include <string.h>
#endif
+#define PPL_BITS_PER_GMP_LIMB (PPL_SIZEOF_MP_LIMB_T*CHAR_BIT)
+
namespace Parma_Polyhedra_Library {
inline
@@ -50,11 +52,11 @@ Bit_Row::Bit_Row(const Bit_Row& y, const Bit_Row& z) {
const mp_size_t y_size = y.vec->_mp_size;
const mp_size_t z_size = z.vec->_mp_size;
if (y_size < z_size) {
- mpz_init2(vec, z_size);
+ mpz_init2(vec, z_size*PPL_BITS_PER_GMP_LIMB);
union_helper(y, z);
}
else {
- mpz_init2(vec, y_size);
+ mpz_init2(vec, y_size*PPL_BITS_PER_GMP_LIMB);
union_helper(z, y);
}
}
@@ -128,7 +130,16 @@ Bit_Row::first_one(mp_limb_t w) {
/*! \relates Bit_Row */
inline void
set_union(const Bit_Row& x, const Bit_Row& y, Bit_Row& z) {
- mpz_ior(z.vec, x.vec, y.vec);
+ const mp_size_t x_size = x.vec->_mp_size;
+ const mp_size_t y_size = y.vec->_mp_size;
+ if (x_size < y_size) {
+ mpz_realloc2(z.vec, y_size*PPL_BITS_PER_GMP_LIMB);
+ z.union_helper(x, y);
+ }
+ else {
+ mpz_realloc2(z.vec, x_size*PPL_BITS_PER_GMP_LIMB);
+ z.union_helper(y, x);
+ }
}
/*! \relates Bit_Row */
diff --git a/src/Polyhedron_nonpublic.cc b/src/Polyhedron_nonpublic.cc
index da60e84..857b302 100644
--- a/src/Polyhedron_nonpublic.cc
+++ b/src/Polyhedron_nonpublic.cc
@@ -1122,15 +1122,9 @@ PPL::Polyhedron::strongly_minimize_constraints() const {
throw std::runtime_error("PPL internal error: "
"strongly_minimize_constraints.");
}
- Bit_Row sat_lines_and_rays;
- set_union(sat_all_but_points, sat_all_but_closure_points,
- sat_lines_and_rays);
- Bit_Row sat_lines_and_closure_points;
- set_union(sat_all_but_rays, sat_all_but_points,
- sat_lines_and_closure_points);
- Bit_Row sat_lines;
- set_union(sat_lines_and_rays, sat_lines_and_closure_points,
- sat_lines);
+ Bit_Row sat_lines_and_rays(sat_all_but_points, sat_all_but_closure_points);
+ Bit_Row sat_lines_and_closure_points(sat_all_but_rays, sat_all_but_points);
+ Bit_Row sat_lines(sat_lines_and_rays, sat_lines_and_closure_points);
// These flags are maintained to later decide if we have to add the
// eps_leq_one constraint and whether or not the constraint system
@@ -1304,8 +1298,7 @@ PPL::Polyhedron::strongly_minimize_generators() const {
if (gs[i].is_point()) {
// Compute the Bit_Row corresponding to the candidate point
// when strict inequality constraints are ignored.
- Bit_Row sat_gi;
- set_union(sat[i], sat_all_but_strict_ineq, sat_gi);
+ Bit_Row sat_gi(sat[i], sat_all_but_strict_ineq);
// Check if the candidate point is actually eps-redundant:
// namely, if there exists another point that saturates
// all the non-strict inequalities saturated by the candidate.
diff --git a/src/conversion.cc b/src/conversion.cc
index 7c0b04b..3249fbd 100644
--- a/src/conversion.cc
+++ b/src/conversion.cc
@@ -676,8 +676,7 @@ PPL::Polyhedron::conversion(Linear_System& source,
// Being the union of `sat[i]' and `sat[j]',
// `new_satrow' corresponds to a ray that saturates all the
// constraints saturated by both `dest[i]' and `dest[j]'.
- Bit_Row new_satrow(sat[i]);
- set_union(new_satrow, sat[j], new_satrow);
+ Bit_Row new_satrow(sat[i], sat[j]);
// Compute the number of common saturators.
// NOTE: this number has to be less than `k' because
More information about the PPL-devel
mailing list