mirror of
https://github.com/Z3Prover/z3
synced 2026-04-16 17:23:25 +00:00
Standardize for-loop increments to prefix form (++i) (#8199)
* Initial plan * Convert postfix to prefix increment in for loops Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Fix member variable increment conversion bug Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Update API generator to produce prefix increments Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
parent
1bf463d77a
commit
2436943794
475 changed files with 3237 additions and 3237 deletions
|
|
@ -16,7 +16,7 @@ static void tst_shl(unsigned src_sz, unsigned const * src, unsigned k,
|
|||
unsigned dst_sz, unsigned const * dst, bool trace = true) {
|
||||
if (trace) {
|
||||
std::cout << "shl({";
|
||||
for (unsigned i = 0; i < src_sz; i++) {
|
||||
for (unsigned i = 0; i < src_sz; ++i) {
|
||||
if (i > 0) std::cout << ", ";
|
||||
std::cout << src[i];
|
||||
}
|
||||
|
|
@ -24,12 +24,12 @@ static void tst_shl(unsigned src_sz, unsigned const * src, unsigned k,
|
|||
}
|
||||
svector<unsigned> actual_dst;
|
||||
actual_dst.resize(dst_sz, 0xAAAAAAAA);
|
||||
for (unsigned sz = 1; sz <= dst_sz; sz++) {
|
||||
for (unsigned sz = 1; sz <= dst_sz; ++sz) {
|
||||
if (trace)
|
||||
std::cout << " for sz = " << sz << std::endl;
|
||||
shl(src_sz, src, k, sz, actual_dst.data());
|
||||
ENSURE(!has_one_at_first_k_bits(sz, actual_dst.data(), k));
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
if (trace && dst[i] != actual_dst[i])
|
||||
std::cout << "UNEXPECTED RESULT at [" << i << "]: " << actual_dst[i] << ", expected: " << dst[i] << "\n";
|
||||
ENSURE(dst[i] == actual_dst[i]);
|
||||
|
|
@ -49,7 +49,7 @@ static void tst_shl(unsigned src_sz, unsigned const * src, unsigned k,
|
|||
svector<unsigned> new_src;
|
||||
new_src.resize(sz, 0xAAAAAAAA);
|
||||
shr(sz, actual_dst.data(), k, new_src.data());
|
||||
for (unsigned i = 0; i < src_sz; i++) {
|
||||
for (unsigned i = 0; i < src_sz; ++i) {
|
||||
if (trace && src[i] != new_src[i]) {
|
||||
std::cout << "shr BUG, inverting shl, at bit[" << i << "], " << new_src[i] << ", expected: " << src[i] << std::endl;
|
||||
}
|
||||
|
|
@ -60,10 +60,10 @@ static void tst_shl(unsigned src_sz, unsigned const * src, unsigned k,
|
|||
if (trace)
|
||||
std::cout << " shift by 1, k times" << std::endl;
|
||||
copy(src_sz, src, dst_sz, actual_dst.data());
|
||||
for (unsigned i = 0; i < k; i++) {
|
||||
for (unsigned i = 0; i < k; ++i) {
|
||||
shl(dst_sz, actual_dst.data(), 1, dst_sz, actual_dst.data());
|
||||
}
|
||||
for (unsigned i = 0; i < dst_sz; i++) {
|
||||
for (unsigned i = 0; i < dst_sz; ++i) {
|
||||
if (trace && dst[i] != actual_dst[i])
|
||||
std::cout << "UNEXPECTED RESULT at [" << i << "]: " << actual_dst[i] << ", expected: " << dst[i] << "\n";
|
||||
ENSURE(dst[i] == actual_dst[i]);
|
||||
|
|
@ -72,7 +72,7 @@ static void tst_shl(unsigned src_sz, unsigned const * src, unsigned k,
|
|||
if (trace)
|
||||
std::cout << " self-shl" << std::endl;
|
||||
shl(src_sz, src, k, src_sz, const_cast<unsigned*>(src));
|
||||
for (unsigned i = 0; i < src_sz; i++) {
|
||||
for (unsigned i = 0; i < src_sz; ++i) {
|
||||
if (trace && src[i] != dst[i])
|
||||
std::cout << "UNEXPECTED RESULT at [" << i << "]: " << src[i] << ", expected: " << dst[i] << "\n";
|
||||
ENSURE(src[i] == actual_dst[i]);
|
||||
|
|
@ -123,7 +123,7 @@ static void tst_shr(unsigned src_sz, unsigned const * src, unsigned k,
|
|||
unsigned const * dst, bool trace = true) {
|
||||
if (trace) {
|
||||
std::cout << "shr({";
|
||||
for (unsigned i = 0; i < src_sz; i++) {
|
||||
for (unsigned i = 0; i < src_sz; ++i) {
|
||||
if (i > 0) std::cout << ", ";
|
||||
std::cout << src[i];
|
||||
}
|
||||
|
|
@ -132,7 +132,7 @@ static void tst_shr(unsigned src_sz, unsigned const * src, unsigned k,
|
|||
svector<unsigned> actual_dst;
|
||||
actual_dst.resize(src_sz, 0xAAAAAAAA);
|
||||
shr(src_sz, src, k, actual_dst.data());
|
||||
for (unsigned i = 0; i < src_sz; i++) {
|
||||
for (unsigned i = 0; i < src_sz; ++i) {
|
||||
if (trace && dst[i] != actual_dst[i])
|
||||
std::cout << "UNEXPECTED RESULT at [" << i << "]: " << actual_dst[i] << ", expected: " << dst[i] << "\n";
|
||||
ENSURE(dst[i] == actual_dst[i]);
|
||||
|
|
@ -149,7 +149,7 @@ static void tst_shr() {
|
|||
static void tst_shl_rand(unsynch_mpz_manager & m, unsigned sz, unsigned k, bool trace = true) {
|
||||
// create a random bitvector of of size sz
|
||||
svector<unsigned> src;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
src.push_back(rand());
|
||||
}
|
||||
// convert src into a mpz number
|
||||
|
|
@ -181,14 +181,14 @@ static void tst_shl_rand(unsynch_mpz_manager & m, unsigned sz, unsigned k, bool
|
|||
dst.push_back(0);
|
||||
dst.push_back(0);
|
||||
unsigned word_shift = (k / 32);
|
||||
for (unsigned i = 0; i < word_shift; i++)
|
||||
for (unsigned i = 0; i < word_shift; ++i)
|
||||
dst.push_back(0);
|
||||
tst_shl(src.size(), src.data(), k, dst.size(), dst.data(), trace);
|
||||
}
|
||||
|
||||
static void tst_shl_rand(unsigned N, unsigned sz, unsigned k, bool trace = false) {
|
||||
unsynch_mpz_manager m;
|
||||
for (unsigned i = 0; i < N; i++) {
|
||||
for (unsigned i = 0; i < N; ++i) {
|
||||
unsigned _sz = rand() % sz;
|
||||
if (_sz == 0)
|
||||
_sz = 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue