summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-06-11 16:01:43 +0100
committerAlasdair Armstrong2018-06-11 16:50:11 +0100
commitd96cd3e8d74b303ff89716294d173754c70cd6b7 (patch)
treea7e68604ccf629509a75f6daa6387bc34fca8257 /lib
parent6b70f78c3c9477d4c5f417ed0a5d96abc19c9fb0 (diff)
More efficient bitfield implementation
Diffstat (limited to 'lib')
-rw-r--r--lib/sail.h31
1 files changed, 23 insertions, 8 deletions
diff --git a/lib/sail.h b/lib/sail.h
index 99b57d8a..319db18d 100644
--- a/lib/sail.h
+++ b/lib/sail.h
@@ -740,6 +740,17 @@ void set_slice_int(mpz_t *rop,
}
}
+// This is a bit of a hack to let us optimize away the Align__1
+// function in aarch64.
+void arm_align(bv_t *rop, const bv_t x_bv, const mpz_t y_mpz) {
+ uint64_t x = mpz_get_ui(*x_bv.bits);
+ uint64_t y = mpz_get_ui(y_mpz);
+ uint64_t z = y * (x / y);
+ mp_bitcnt_t n = x_bv.len;
+ mpz_set_ui(*rop->bits, safe_rshift(UINT64_MAX, 64l - (n - 1)) & z);
+ rop->len = n;
+}
+
void vector_update_subrange_bv_t(bv_t *rop,
const bv_t op,
const mpz_t n_mpz,
@@ -765,16 +776,20 @@ void vector_subrange_bv_t(bv_t *rop, const bv_t op, const mpz_t n_mpz, const mpz
uint64_t n = mpz_get_ui(n_mpz);
uint64_t m = mpz_get_ui(m_mpz);
- mpz_set_ui(*rop->bits, 0ul);
rop->len = n - (m - 1ul);
+ mpz_fdiv_q_2exp(*rop->bits, *op.bits, m);
+ normalise_bv_t(rop);
- for (uint64_t i = 0; i < rop->len; i++) {
- if (mpz_tstbit(*op.bits, i + m)) {
- mpz_setbit(*rop->bits, i);
- } else {
- mpz_clrbit(*rop->bits, i);
- }
- }
+ /* mpz_set_ui(*rop->bits, 0ul); */
+ /* rop->len = n - (m - 1ul); */
+
+ /* for (uint64_t i = 0; i < rop->len; i++) { */
+ /* if (mpz_tstbit(*op.bits, i + m)) { */
+ /* mpz_setbit(*rop->bits, i); */
+ /* } else { */
+ /* mpz_clrbit(*rop->bits, i); */
+ /* } */
+ /* } */
}
int bitvector_access(const bv_t op, const mpz_t n_mpz) {