Skip to content

Commit 89fe06c

Browse files
committed
Change twice used large const table to static
This table is used twice in core::num::dec2flt::algorithm::power_of_ten. According to the semantics of const, a separate huge definition of the table is inlined at both places. fn power_of_ten(e: i16) -> Fp { assert!(e >= table::MIN_E); let i = e - table::MIN_E; let sig = table::POWERS.0[i as usize]; let exp = table::POWERS.1[i as usize]; Fp { f: sig, e: exp } } Theoretically this gets cleaned up by optimization passes, but in practice I am experiencing a miscompile from LTO on this code. Making the table a static, which would only be defined a single time and not require attention from LTO, eliminates the miscompile and seems semantically more appropriate anyway. A separate bug report on the LTO bug is forthcoming.
1 parent a9eb501 commit 89fe06c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/src/num/dec2flt/table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub const MIN_E: i16 = -305;
55
pub const MAX_E: i16 = 305;
66

77
#[rustfmt::skip]
8-
pub const POWERS: ([u64; 611], [i16; 611]) = (
8+
pub static POWERS: ([u64; 611], [i16; 611]) = (
99
[
1010
0xe0b62e2929aba83c,
1111
0x8c71dcd9ba0b4926,

0 commit comments

Comments
 (0)