diff options
Diffstat (limited to 'test/lit/passes/optimize-instructions-strings.wast')
-rw-r--r-- | test/lit/passes/optimize-instructions-strings.wast | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/lit/passes/optimize-instructions-strings.wast b/test/lit/passes/optimize-instructions-strings.wast new file mode 100644 index 000000000..9104f970d --- /dev/null +++ b/test/lit/passes/optimize-instructions-strings.wast @@ -0,0 +1,44 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. +;; RUN: wasm-opt %s -all --optimize-instructions -S -o - | filecheck %s + +(module + ;; CHECK: (func $string.checks (type $ref|string|_ref|string|_=>_none) (param $a (ref string)) (param $b (ref string)) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (string.eq + ;; CHECK-NEXT: (local.get $a) + ;; CHECK-NEXT: (local.get $b) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.and + ;; CHECK-NEXT: (string.compare + ;; CHECK-NEXT: (local.get $a) + ;; CHECK-NEXT: (local.get $b) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $string.checks (param $a (ref string)) (param $b (ref string)) + ;; Equals returns 0/1, so the &1 operation can be removed. + (drop + (i32.and + (string.eq + (local.get $a) + (local.get $b) + ) + (i32.const 1) + ) + ) + ;; Compare returns -1/0/1, so we cannot change anything here. + (drop + (i32.and + (string.compare + (local.get $a) + (local.get $b) + ) + (i32.const 1) + ) + ) + ) +) |