Skip to content

Commit c0ee5bf

Browse files
committed
Revert "work around compiler bug rust-lang/rust#86693"
turns out we just needed to align $sp to 16-byte boundaries This reverts commit 279bbc5.
1 parent beea131 commit c0ee5bf

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

src/scalar.rs

+4-21
Original file line numberDiff line numberDiff line change
@@ -917,17 +917,8 @@ impl Scalar {
917917

918918
let mut naf = [0i8; 256];
919919

920-
// work-around for https://github.com/rust-lang/rust/issues/86693
921-
// riscv32i targets mis-align u64 types, leading to the lower 32 bits being aliased to the upper 32 bits
922-
// the AlignedU64Slice wrapper forces the enclosed structure to be aligned, thus avoiding this problem.
923-
#[repr(align(32))]
924-
struct AlignedU64Slice([u64; 5]);
925-
926-
let mut x_u64 = AlignedU64Slice([0u64; 5]);
927-
LittleEndian::read_u64_into(&self.bytes, &mut x_u64.0[0..4]);
928-
929-
#[cfg(feature = "betrusted")]
930-
log::trace!("x_u64: {:?}", x_u64.0);
920+
let mut x_u64 = [0u64; 5];
921+
LittleEndian::read_u64_into(&self.bytes, &mut x_u64[0..4]);
931922

932923
let width = 1 << w;
933924
let window_mask = width - 1;
@@ -941,10 +932,10 @@ impl Scalar {
941932
let bit_buf: u64;
942933
if bit_idx < 64 - w {
943934
// This window's bits are contained in a single u64
944-
bit_buf = x_u64.0[u64_idx] >> bit_idx;
935+
bit_buf = x_u64[u64_idx] >> bit_idx;
945936
} else {
946937
// Combine the current u64's bits with the bits from the next u64
947-
bit_buf = (x_u64.0[u64_idx] >> bit_idx) | (x_u64.0[1+u64_idx] << (64 - bit_idx));
938+
bit_buf = (x_u64[u64_idx] >> bit_idx) | (x_u64[1+u64_idx] << (64 - bit_idx));
948939
}
949940

950941
// Add the carry into the current window
@@ -960,17 +951,9 @@ impl Scalar {
960951
}
961952

962953
if window < width/2 {
963-
#[cfg(feature = "betrusted")]
964-
log::trace!("carry 0 width {} naf[{}] = {}; c.{} bb.{:x} wm.{} idx64.{} idxbit.{} xu64[0].{:x}", width, pos, window,
965-
carry, bit_buf, window_mask, u64_idx, bit_idx, x_u64.0[0],
966-
);
967954
carry = 0;
968955
naf[pos] = window as i8;
969956
} else {
970-
#[cfg(feature = "betrusted")]
971-
log::trace!("carry 1 width {} naf[{}] = {}/{}; c.{} bb.{:x} wm.{} idx64.{} idxbit.{} xu64[0].{:x}", width, pos, window, (window as i8).wrapping_sub(width as i8),
972-
carry, bit_buf, window_mask, u64_idx, bit_idx, x_u64.0[0]
973-
);
974957
carry = 1;
975958
naf[pos] = (window as i8).wrapping_sub(width as i8);
976959
}

0 commit comments

Comments
 (0)