Bug 1707774 Comment 13 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Getting rid of loop by using v2 more:
```
new WebAssembly.Module(wasmTextToBinary(`
(module
  (func (result i64)
    (local $n i64)                ;; zero
    (if (global.get $flag)        ;; give $flag high priority;
        (return (i64.const 7)))   ;;  do not touch $n
    (if (global.get $flag)
        (return (i64.const 8)))
    (if (global.get $flag)
        (return (i64.const 9)))
    (if (global.get $flag)
        (return (i64.const 10)))
    (if (global.get $flag)
        (return (i64.const 11)))
    (if (global.get $flag)
        (return (i64.const 12)))
    (local.set $n                 ;; $n = zero, but this is
      (i64.mul (local.get $n)     ;;  not known because i64.mul
               (local.get $n)))   ;;   is not constant folded
    (if (global.get $flag)        ;; conditionally
        (return (local.get $n)))  ;;  read $n
    (global.set $flag             ;; introduce
      (i32.const 1))              ;;  global effect
    (i64.load (i32.const 48))     ;; maybe traps
    drop                          ;;  but ignore result
    (local.get $n))               ;; read $n
  (memory 1)
  (global $flag (mut i32) (i32.const 2)))
`))
```
Getting rid of loop by using v2 more, and get rid of the setting of $flag
```
new WebAssembly.Module(wasmTextToBinary(`
(module
  (func (result i64)
    (local $n i64)                ;; zero
    (if (global.get $flag)        ;; give $flag high priority;
        (return (i64.const 7)))   ;;  do not touch $n
    (if (global.get $flag)
        (return (i64.const 8)))
    (if (global.get $flag)
        (return (i64.const 9)))
    (if (global.get $flag)
        (return (i64.const 10)))
    (if (global.get $flag)
        (return (i64.const 11)))
    (if (global.get $flag)
        (return (i64.const 12)))
    (local.set $n                 ;; $n = zero, but this is
      (i64.mul (local.get $n)     ;;  not known because i64.mul
               (local.get $n)))   ;;   is not constant folded
    (if (global.get $flag)        ;; conditionally
        (return (local.get $n)))  ;;  read $n
    (i64.load (i32.const 48))     ;; maybe traps
    drop                          ;;  but ignore result
    (local.get $n))               ;; read $n
  (memory 1)
  (global $flag (mut i32) (i32.const 2)))
`))
```
Getting rid of loop by using v2 more, and get rid of the setting of $flag.  I'm starting to suspect that the effect of the load is simply to make x0 be allocated to something other than $n so that there can be some turbulence in the function tail.
```
new WebAssembly.Module(wasmTextToBinary(`
(module
  (func (result i64)
    (local $n i64)                ;; zero
    (if (global.get $flag)        ;; give $flag high priority;
        (return (i64.const 7)))   ;;  do not touch $n
    (if (global.get $flag)
        (return (i64.const 8)))
    (if (global.get $flag)
        (return (i64.const 9)))
    (if (global.get $flag)
        (return (i64.const 10)))
    (if (global.get $flag)
        (return (i64.const 11)))
    (if (global.get $flag)
        (return (i64.const 12)))
    (local.set $n                 ;; $n = zero, but this is
      (i64.mul (local.get $n)     ;;  not known because i64.mul
               (local.get $n)))   ;;   is not constant folded
    (if (global.get $flag)        ;; conditionally
        (return (local.get $n)))  ;;  read $n
    (i64.load (i32.const 48))     ;; maybe traps
    drop                          ;;  but ignore result
    (local.get $n))               ;; read $n
  (memory 1)
  (global $flag (mut i32) (i32.const 2)))
`))
```
Getting rid of loop by using v2 more, and get rid of the setting of $flag.  I'm starting to suspect that the effect of the load is simply to make x0 be allocated to something other than $n in the function tail.
```
new WebAssembly.Module(wasmTextToBinary(`
(module
  (func (result i64)
    (local $n i64)                ;; zero
    (if (global.get $flag)        ;; give $flag high priority;
        (return (i64.const 7)))   ;;  do not touch $n
    (if (global.get $flag)
        (return (i64.const 8)))
    (if (global.get $flag)
        (return (i64.const 9)))
    (if (global.get $flag)
        (return (i64.const 10)))
    (if (global.get $flag)
        (return (i64.const 11)))
    (if (global.get $flag)
        (return (i64.const 12)))
    (local.set $n                 ;; $n = zero, but this is
      (i64.mul (local.get $n)     ;;  not known because i64.mul
               (local.get $n)))   ;;   is not constant folded
    (if (global.get $flag)        ;; conditionally
        (return (local.get $n)))  ;;  read $n
    (i64.load (i32.const 48))     ;; maybe traps
    drop                          ;;  but ignore result
    (local.get $n))               ;; read $n
  (memory 1)
  (global $flag (mut i32) (i32.const 2)))
`))
```

Back to Bug 1707774 Comment 13