File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ struct Vacuum : public WalkerPass<PostWalker<Vacuum>> {
4949
5050 // returns nullptr if curr is dead, curr if it must stay as is, or another node if it can be replaced
5151 Expression* optimize (Expression* curr, bool resultUsed) {
52+ // an unreachable node must not be changed
53+ if (curr->type == unreachable) return curr;
5254 while (1 ) {
5355 switch (curr->_id ) {
5456 case Expression::Id::NopId: return nullptr ; // never needed
Original file line number Diff line number Diff line change 2828 (nop)
2929 )
3030 (func $unary (type $2) (result f32)
31- (unreachable)
31+ (f32.abs
32+ (unreachable)
33+ )
3234 )
3335 (func $binary (type $2) (result f32)
3436 (drop
35- (unreachable)
37+ (f32.add
38+ (unreachable)
39+ (f32.const 3)
40+ )
3641 )
3742 )
3843 (func $select (type $3) (result i32)
3944 (drop
40- (unreachable)
45+ (select
46+ (unreachable)
47+ (i32.const 4)
48+ (i32.const 5)
49+ )
4150 )
4251 )
4352 (func $block-to-one (type $0)
198207 (local $2 i32)
199208 (nop)
200209 )
210+ (func $a (type $0)
211+ (block $block
212+ (i32.store
213+ (i32.const 1)
214+ (i32.const 2)
215+ )
216+ (f64.div
217+ (f64.const -nan:0xfffffffffa361)
218+ (loop $label$1
219+ (br $label$1)
220+ )
221+ )
222+ )
223+ )
201224)
Original file line number Diff line number Diff line change 509509 )
510510 )
511511 )
512+ (func $a
513+ (block
514+ (i32.store (i32.const 1 ) (i32.const 2 ))
515+ (f64.div
516+ (f64.const -nan:0xfffffffffa361 )
517+ (loop $label$1 ;; unreachable, so the div is too. keep
518+ (br $label$1 )
519+ )
520+ )
521+ )
522+ )
512523)
You can’t perform that action at this time.
0 commit comments