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;