This shows the problem. It appears to be a LICM problem. With the loop removed, GVN does not common up the duplicate expressions `(i32.mul (local.get $$i) (i32.const 101))` in each arm, which is good. But with the loop enabled all of them are lifted to the top level (and not commoned up).
Bug 1708381 Comment 18 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
This shows the problem. It appears to be a LICM problem. With the loop removed, GVN does not common up the duplicate expressions `(i32.mul (local.get $$i) (i32.const 101))` in each arm, which is good. But with the loop enabled all of them are lifted to the top level (and not commoned up). (Later: I meant: run with `IONFLAGS=licm,gvn,dump-mir-expr`)