Skip to content

Commit 055a82d

Browse files
committed
Share minor powers with float cache
1 parent ed4390a commit 055a82d

17 files changed

Lines changed: 3530 additions & 3352 deletions

‎std/assembly/util/dtoa.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,13 @@ import { DIGITS, MAX_DOUBLE_LENGTH } from "./number";
206206
let j = i + 10;
207207
let major = (j * 293) >>> 13; // exact j / 28 for j in [10,627]
208208
let minor = j - major * 28;
209-
let m = load<u64>(POW10_MINOR + (<usize>minor << 3));
209+
let m: u64;
210+
if (ASC_OPTIMIZE_LEVEL >= 3 && ASC_SHRINK_LEVEL == 0) {
211+
// The minor factors are POW10_FLOAT_HI[44..17] in reverse order.
212+
m = load<u64>(POW10_FLOAT_HI + (<usize>(44 - minor) << 3));
213+
} else {
214+
m = load<u64>(POW10_MINOR + (<usize>minor << 3));
215+
}
210216
let hoff = POW10_MAJOR + (<usize>major << 4);
211217
let hHi = load<u64>(hoff);
212218
let hLo = load<u64>(hoff, 8);

‎tests/compiler/issues/2873.debug.wat‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5944,6 +5944,10 @@
59445944
i32.mul
59455945
i32.sub
59465946
local.set $minor
5947+
i32.const 0
5948+
i32.const 3
5949+
i32.ge_s
5950+
drop
59475951
i32.const 1808
59485952
local.get $minor
59495953
i32.const 3
@@ -6348,6 +6352,10 @@
63486352
i32.mul
63496353
i32.sub
63506354
local.set $minor|105
6355+
i32.const 0
6356+
i32.const 3
6357+
i32.ge_s
6358+
drop
63516359
i32.const 1808
63526360
local.get $minor|105
63536361
i32.const 3
@@ -6954,6 +6962,10 @@
69546962
i32.mul
69556963
i32.sub
69566964
local.set $minor|199
6965+
i32.const 0
6966+
i32.const 3
6967+
i32.ge_s
6968+
drop
69576969
i32.const 1808
69586970
local.get $minor|199
69596971
i32.const 3
@@ -7358,6 +7370,10 @@
73587370
i32.mul
73597371
i32.sub
73607372
local.set $minor|245
7373+
i32.const 0
7374+
i32.const 3
7375+
i32.ge_s
7376+
drop
73617377
i32.const 1808
73627378
local.get $minor|245
73637379
i32.const 3
@@ -7956,6 +7972,10 @@
79567972
i32.mul
79577973
i32.sub
79587974
local.set $minor|335
7975+
i32.const 0
7976+
i32.const 3
7977+
i32.ge_s
7978+
drop
79597979
i32.const 1808
79607980
local.get $minor|335
79617981
i32.const 3

0 commit comments

Comments
 (0)