Stream: git-wasmtime

Topic: wasmtime / PR #15201 cranelift: fix LICM hoisting across ...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 08 2026 at 16:38):

wraitii opened PR #15201 from wraitii:fix/licm-separate-loops to bytecodealliance:main:

The elaborator’s loop stack can include a loop that dominates the current block but has already exited. Treating the stack as a nested loop chain can hoist instructions across that unrelated loop, extending live ranges without reducing repeated work.

Pseudocode example of the issue:

hot = n
do:
    hot -= 1
while hot != 0

cold = n
do:
    step = unsigned(n) >> (n & 63)
    cold -= step
while cold != 0

Incorrect placement before the fix:

step = unsigned(n) >> (n & 63)  // hoisted across the unrelated hot loop
hot = n
do:
    hot -= 1
while hot != 0

cold = n
do:
    cold -= step
while cold != 0

The fix places step after the hot loop, before the cold loop. The code remains correct in both cases but the generation is significantly worse, especially as this increases register pressure.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 08 2026 at 16:38):

wraitii removed the review request for wasmtime-compiler-reviewers from PR #15201.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 08 2026 at 16:38):

wraitii requested alexcrichton for a review on PR #15201.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 08 2026 at 16:38):

wraitii requested wasmtime-compiler-reviewers for a review on PR #15201.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 08 2026 at 16:39):

wraitii edited PR #15201:

The elaborator’s loop stack can include a loop that dominates the current block but has already exited. Treating the stack as a nested loop chain can hoist instructions across that unrelated loop, extending live ranges without reducing repeated work.

Pseudocode example of the issue:

hot = n
do:
    hot -= 1
    if random() > 0.5: // Un-necessary but this shows that hoisting before is generally incorrect.
        return
while hot != 0

cold = n
do:
    step = unsigned(n) >> (n & 63)
    cold -= step
while cold != 0

Incorrect placement before the fix:

step = unsigned(n) >> (n & 63)  // hoisted across the unrelated hot loop
hot = n
do:
    hot -= 1
    if random() > 0.5:
        return
while hot != 0

cold = n
do:
    cold -= step
while cold != 0

The fix places step after the hot loop, before the cold loop. The code remains correct in both cases but the generation is significantly worse, especially as this increases register pressure.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 08 2026 at 18:44):

github-actions[bot] added the label cranelift on PR #15201.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 13:40):

alexcrichton removed the review request for alexcrichton from PR #15201.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 13:40):

alexcrichton requested fitzgen for a review on PR #15201.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 16:41):

wraitii edited PR #15201:

The elaborator’s loop stack can include a loop that dominates the current block but has already exited. Treating the stack as a nested loop chain can hoist instructions across that unrelated loop, extending live ranges without reducing repeated work.

Pseudocode example of the issue:

hot = n
do:
    hot -= 1
    if random() > 0.5: // Un-necessary but this shows that hoisting before is generally incorrect.
        return
while hot != 0

cold = n
do:
    step = unsigned(n) >> (n & 63)
    cold -= step
while cold != 0

Incorrect placement before the fix:

step = unsigned(n) >> (n & 63)  // hoisted across the unrelated hot loop
hot = n
do:
    hot -= 1
    if random() > 0.5:
        return
while hot != 0

cold = n
do:
    cold -= step
while cold != 0

The fix places step after the hot loop, before the cold loop. The code remains correct in both cases but the generation is significantly worse, especially as this increases register pressure.


PR written by Astra, the diff reads correct to me for the issue but i've been peepholing these, so feel free to pong back.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 16:42):

wraitii commented on PR #15201:

Ran Sightglass, it reports no significant changes on 29 workloads, 20 samples per engine.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 18:02):

:thumbs_up: cfallin submitted PR review:

Thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 18:02):

cfallin added PR #15201 cranelift: fix LICM hoisting across separate loops to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 19:13):

:check: cfallin merged PR #15201.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 19:13):

cfallin removed PR #15201 cranelift: fix LICM hoisting across separate loops from the merge queue.


Last updated: Nov 19 2026 at 20:05 UTC