Bug 1640669 Comment 3 Edit History

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

Also, we want to constant-fold these when we can, if it's not too much work.  I've seen emscripten generate some strange code where it tests any_true of a constant value, probably as a result of several levels of hoisting and rewriting.  Here's the start of the output of the mandelbrot program at -O3:
```
  (func (;2;) (type 2) (param i32 i32) (result i32)
    (local i32 i32 f32 v128 v128 v128 v128 v128 v128 v128 v128 v128)
    block  ;; label = @1
      i32.const -1
      i32x4.splat
      local.tee 11
      i32x4.any_true
      if  ;; label = @2
        ...
```
Note, though, that to effectively constant fold that condition we have to constant fold the tee, that is, a tee of a constant should propagate the constant.  Not completely obvious to me what happens in WasmIonCompile right now.
Also, we want to constant-fold these when we can, if it's not too much work.  I've seen emscripten generate some strange code where it tests any_true of a constant value, probably as a result of several levels of hoisting and rewriting.  Here's the start of the output of the mandelbrot program at -O3:
```
  (func (;2;) (type 2) (param i32 i32) (result i32)
    (local i32 i32 f32 v128 v128 v128 v128 v128 v128 v128 v128 v128)
    block  ;; label = @1
      i32.const -1
      i32x4.splat
      local.tee 11
      i32x4.any_true
      if  ;; label = @2
        ...
```
Note, though, that to effectively constant fold that condition we have to constant fold the tee, that is, a tee of a constant should propagate the constant.  Not completely obvious to me what happens in WasmIonCompile right now.

Edit: tee seems to do the right thing, the MDefinition flows through the tee.
Also, we want to constant-fold these when we can, if it's not too much work.  I've seen emscripten generate some strange code where it tests any_true of a constant value, probably as a result of several levels of hoisting and rewriting.  Here's the start of the output of the mandelbrot program at -O3:
```
  (func (;2;) (type 2) (param i32 i32) (result i32)
    (local i32 i32 f32 v128 v128 v128 v128 v128 v128 v128 v128 v128)
    block  ;; label = @1
      i32.const -1
      i32x4.splat
      local.tee 11
      i32x4.any_true
      if  ;; label = @2
        ...
```
Note, though, that to effectively constant fold that condition we have to constant fold the tee, that is, a tee of a constant should propagate the constant.  Not completely obvious to me what happens in WasmIonCompile right now.

Edit: tee seems to do the right thing, the MDefinition flows through the tee.

Edit: the constant folding should be a work item of its own, separate from this bug.

Back to Bug 1640669 Comment 3