summaryrefslogtreecommitdiff
path: root/test/lit/passes/local-cse.wast
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2021-08-17 14:26:24 -0700
committerGitHub <noreply@github.com>2021-08-17 21:26:24 +0000
commitb82be0fe1abd3c56cc85150c76efbd66db6fe32e (patch)
tree886cf25d9cfd2bd38c18cbdcf60b0c7386a1f50d /test/lit/passes/local-cse.wast
parentd1bea49163be364d6f8b277b35510555211374b5 (diff)
downloadbinaryen-b82be0fe1abd3c56cc85150c76efbd66db6fe32e.tar.gz
binaryen-b82be0fe1abd3c56cc85150c76efbd66db6fe32e.tar.bz2
binaryen-b82be0fe1abd3c56cc85150c76efbd66db6fe32e.zip
LocalCSE: ignore traps (#4085)
If we replace A A A with (local.set A) (local.get) (local.get) then it is ok for A to trap (so long as it does so deterministically), as if it does trap then the first appearance will do so, and the others not be reached anyhow. This helps GC code as often there are repeated struct.gets and such that may trap.
Diffstat (limited to 'test/lit/passes/local-cse.wast')
-rw-r--r--test/lit/passes/local-cse.wast15
1 files changed, 8 insertions, 7 deletions
diff --git a/test/lit/passes/local-cse.wast b/test/lit/passes/local-cse.wast
index 5cdf712f8..6d1b8a824 100644
--- a/test/lit/passes/local-cse.wast
+++ b/test/lit/passes/local-cse.wast
@@ -266,20 +266,21 @@
)
;; CHECK: (func $loads
+ ;; CHECK-NEXT: (local $0 i32)
;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (i32.load
- ;; CHECK-NEXT: (i32.const 10)
+ ;; CHECK-NEXT: (local.tee $0
+ ;; CHECK-NEXT: (i32.load
+ ;; CHECK-NEXT: (i32.const 10)
+ ;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
- ;; CHECK-NEXT: (i32.load
- ;; CHECK-NEXT: (i32.const 10)
- ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $loads
- ;; The possible trap on loads prevents optimization.
- ;; TODO: optimize that too
+ ;; The possible trap on loads does not prevent optimization, since if we
+ ;; trap then it doesn't matter that we replaced the later expression.
(drop
(i32.load (i32.const 10))
)