mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-28 06:53:42 +08:00
A speculative integer loop's failed check used to continue at the failed statement inside the ordinary copy. That gave the ordinary copy a second entry, so LLVM saw an irreducible cycle and did not hoist its invariant loads or keep its values in registers. A loop whose check fails on every entry, such as an inner loop over fractional fields, then ran every iteration in that unoptimized copy. A failed check now continues in a third copy that is entered only from the fast copy: it re-executes the failed statement, the rest of the body and the update, then jumps to the ordinary copy's header. The ordinary copy has a single entry and stays a natural loop. Each loop site also counts its entries in a row whose fast copy bailed. A fast copy that completes a speculated write and leaves the loop clears the count, and after 8 bailing entries in a row the site runs the ordinary copy only. The count is a hint, read and written with unordered atomics: both copies give the same results.