From 660ddfd90ed3078aed5d1dd5aa19f90763f6b0ec Mon Sep 17 00:00:00 2001 From: Chris Tate Date: Tue, 27 Oct 2026 08:41:05 -0500 Subject: [PATCH] Keep the view-header test's loops speculative Module number globals are now proven int32 through their writes, so the test's generator state starts from a value no analysis bounds to keep its loops on the speculative path. Format int32-slots.ts. --- packages/compiler/src/ir/int32-slots.ts | 3 +-- packages/compiler/test/speculative-loop-emission.test.ts | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/compiler/src/ir/int32-slots.ts b/packages/compiler/src/ir/int32-slots.ts index 465f6c683..6d234831d 100644 --- a/packages/compiler/src/ir/int32-slots.ts +++ b/packages/compiler/src/ir/int32-slots.ts @@ -1722,8 +1722,7 @@ export function analyzeInt32Slots(mod: IrModule, inputs: Int32SlotInputs = {}): if (s.kind === "assign") { boxWrite(s.localId, s.value); globalWrite(s.localId, s.value); - } - else if (s.kind === "varDecl" && s.init) boxWrite(s.localId, s.init); + } else if (s.kind === "varDecl" && s.init) boxWrite(s.localId, s.init); if (s.kind === "fieldSet") { const family = slots.family(s.className, s.field); if (!family || !slots.hasFamily(family)) return; diff --git a/packages/compiler/test/speculative-loop-emission.test.ts b/packages/compiler/test/speculative-loop-emission.test.ts index dcec6d8af..52b3c0c07 100644 --- a/packages/compiler/test/speculative-loop-emission.test.ts +++ b/packages/compiler/test/speculative-loop-emission.test.ts @@ -188,9 +188,10 @@ test("a speculative loop reads its views' header fields once, before its copies" // A view held by a const local or by a parameter is the same view in // every iteration. Its data pointer is read before the branch to the fast // copy, and no copy (ordinary, fast, or the one a failed check resumes - // in) reads it again. + // in) reads it again. `last` starts from a value no analysis bounds, + // so the loops speculate on `l`. const llvm = await emitLlvm(` -let last = 42; +let last = Number(process.argv[2] ?? "42"); function fill(array: ArrayBuffer, count: number): void { const buf = new Float64Array(array); let l = last;