Rollup merge of #82676 - dtolnay:powers, r=Mark-Simulacrum
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.
5233edcf1c/library/core/src/num/dec2flt/algorithm.rs (L16-L22)
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.
Original addition of `const` is from #27307.
This commit is contained in:
commit
9a0ac7cb5f
@ -5,7 +5,7 @@ pub const MIN_E: i16 = -305;
|
||||
pub const MAX_E: i16 = 305;
|
||||
|
||||
#[rustfmt::skip]
|
||||
pub const POWERS: ([u64; 611], [i16; 611]) = (
|
||||
pub static POWERS: ([u64; 611], [i16; 611]) = (
|
||||
[
|
||||
0xe0b62e2929aba83c,
|
||||
0x8c71dcd9ba0b4926,
|
||||
|
@ -113,7 +113,7 @@ def print_proper_powers():
|
||||
print()
|
||||
print("#[rustfmt::skip]")
|
||||
typ = "([u64; {0}], [i16; {0}])".format(len(powers))
|
||||
print("pub const POWERS: ", typ, " = (", sep='')
|
||||
print("pub static POWERS: ", typ, " = (", sep='')
|
||||
print(" [")
|
||||
for z in powers:
|
||||
print(" 0x{:x},".format(z.sig))
|
||||
|
Loading…
x
Reference in New Issue
Block a user