Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/ir/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,10 @@ class EffectAnalyzer {
parent.isAtomic = true;
}
void visitPause(Pause* curr) {
// It's not much of a problem if pause gets reordered with anything, but
// we don't want it to be removed entirely.
parent.isAtomic = true;
// We don't want this to be moved out of loops, but it doesn't otherwises
// matter much how it gets reordered. Say we transfer control as a coarse
// approximation of this.
parent.branchesOut = true;
}
void visitSIMDExtract(SIMDExtract* curr) {}
void visitSIMDReplace(SIMDReplace* curr) {}
Expand Down
35 changes: 30 additions & 5 deletions test/lit/passes/licm.wast
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.

;; RUN: foreach %s %t wasm-opt --licm -S -o - | filecheck %s
;; RUN: foreach %s %t wasm-opt -all --licm -S -o - | filecheck %s

(module
(memory 10 20)
Expand All @@ -11,7 +11,7 @@

;; CHECK: (memory $0 10 20)

;; CHECK: (func $unreachable-get
;; CHECK: (func $unreachable-get (type $1)
;; CHECK-NEXT: (local $x i32)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (local.get $x)
Expand All @@ -35,7 +35,7 @@
)
)

;; CHECK: (func $unreachable-get-call (param $p i32)
;; CHECK: (func $unreachable-get-call (type $0) (param $p i32)
;; CHECK-NEXT: (local $x i32)
;; CHECK-NEXT: (loop $loop
;; CHECK-NEXT: (unreachable)
Expand All @@ -56,7 +56,7 @@
)
)

;; CHECK: (func $unreachable-get-store (param $p i32)
;; CHECK: (func $unreachable-get-store (type $0) (param $p i32)
;; CHECK-NEXT: (local $x i32)
;; CHECK-NEXT: (loop $loop
;; CHECK-NEXT: (unreachable)
Expand All @@ -78,5 +78,30 @@
)
)
)
)

;; CHECK: (func $pause (type $0) (param $p i32)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: (loop $loop
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: (pause)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: )
;; CHECK-NEXT: (br $loop)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $pause (param $p i32)
;; We don't want pause to be moved out of loops. In principle we should be
;; able to move side-effect-free expressions back before the pause, but we
;; currently do not. Pause is rare and specialized enough that this shouldn't
;; be a problem.
(loop $loop
(drop (i32.const 0))
(pause)
(drop (i32.const 1))
(br $loop)
)
)
)
Loading