summaryrefslogtreecommitdiff
path: root/test/lit/passes
diff options
context:
space:
mode:
Diffstat (limited to 'test/lit/passes')
-rw-r--r--test/lit/passes/vacuum-strings.wast84
1 files changed, 84 insertions, 0 deletions
diff --git a/test/lit/passes/vacuum-strings.wast b/test/lit/passes/vacuum-strings.wast
new file mode 100644
index 000000000..6925d52e6
--- /dev/null
+++ b/test/lit/passes/vacuum-strings.wast
@@ -0,0 +1,84 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
+;; RUN: wasm-opt %s --vacuum -all -S -o - | filecheck %s
+
+(module
+ ;; CHECK: (func $compare (type $0)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (string.compare
+ ;; CHECK-NEXT: (string.const "hello")
+ ;; CHECK-NEXT: (ref.null none)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (string.compare
+ ;; CHECK-NEXT: (ref.null none)
+ ;; CHECK-NEXT: (string.const "world")
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (string.compare
+ ;; CHECK-NEXT: (ref.null none)
+ ;; CHECK-NEXT: (ref.null none)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $compare
+ ;; We cannot vacuum away compares that might trap.
+ (drop
+ (string.compare
+ (string.const "hello")
+ (string.const "world")
+ )
+ )
+ (drop
+ (string.compare
+ (string.const "hello")
+ (ref.null none)
+ )
+ )
+ (drop
+ (string.compare
+ (ref.null none)
+ (string.const "world")
+ )
+ )
+ (drop
+ (string.compare
+ (ref.null none)
+ (ref.null none)
+ )
+ )
+ )
+
+ ;; CHECK: (func $eq (type $0)
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ (func $eq
+ ;; Equals, however, never traps so all these can be removed.
+ (drop
+ (string.eq
+ (string.const "hello")
+ (string.const "world")
+ )
+ )
+ (drop
+ (string.eq
+ (string.const "hello")
+ (ref.null none)
+ )
+ )
+ (drop
+ (string.eq
+ (ref.null none)
+ (string.const "world")
+ )
+ )
+ (drop
+ (string.eq
+ (ref.null none)
+ (ref.null none)
+ )
+ )
+ )
+)
+