diff options
author | Alon Zakai <azakai@google.com> | 2023-02-16 11:49:37 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-16 19:49:37 +0000 |
commit | 70f51822318231214c435567edfbd54158097261 (patch) | |
tree | c958e3108a3a808b474d837110cde1ab73f462b0 /test/lit/passes/optimize-instructions-strings.wast | |
parent | cd90ef436e9038331ce52e24db3ead6312426e8b (diff) | |
download | binaryen-70f51822318231214c435567edfbd54158097261.tar.gz binaryen-70f51822318231214c435567edfbd54158097261.tar.bz2 binaryen-70f51822318231214c435567edfbd54158097261.zip |
[Strings] string.compare does not return a bool (#5497)
string.eq does, and when we added string.compare I forgot to adjust the
boolean property for that new opcode.
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) + ) + ) + ) +) |