summaryrefslogtreecommitdiff
path: root/test/lit/passes/optimize-instructions-memory64.wast
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-11-06 15:33:14 -0800
committerGitHub <noreply@github.com>2024-11-06 15:33:14 -0800
commit6724ebe4b9e184a9a73ce82e8b8782f7f5a21d1a (patch)
treefe2d4682eefcf0addd42de8abac626cb0b07eb6a /test/lit/passes/optimize-instructions-memory64.wast
parent40210446937cbef7d73606e4331cb6a782e2a875 (diff)
downloadbinaryen-6724ebe4b9e184a9a73ce82e8b8782f7f5a21d1a.tar.gz
binaryen-6724ebe4b9e184a9a73ce82e8b8782f7f5a21d1a.tar.bz2
binaryen-6724ebe4b9e184a9a73ce82e8b8782f7f5a21d1a.zip
[wasm64] Handle 64-bit overflow in optimizeMemoryAccess (#7057)
When we combine a load/store offset with a const, we must not overflow, as the semantics of offsets do not wrap.
Diffstat (limited to 'test/lit/passes/optimize-instructions-memory64.wast')
-rw-r--r--test/lit/passes/optimize-instructions-memory64.wast31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/lit/passes/optimize-instructions-memory64.wast b/test/lit/passes/optimize-instructions-memory64.wast
new file mode 100644
index 000000000..f74dad7a8
--- /dev/null
+++ b/test/lit/passes/optimize-instructions-memory64.wast
@@ -0,0 +1,31 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
+;; RUN: wasm-opt %s --optimize-instructions -all -S -o - | filecheck %s
+
+(module
+ ;; CHECK: (memory $0 i64 16 17)
+ (memory $0 i64 16 17)
+
+ ;; CHECK: (func $offsets (type $0)
+ ;; CHECK-NEXT: (i64.store
+ ;; CHECK-NEXT: (i64.const 10)
+ ;; CHECK-NEXT: (i64.const 42)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (f32.store offset=4
+ ;; CHECK-NEXT: (i64.const -3)
+ ;; CHECK-NEXT: (f32.const 3.141590118408203)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $offsets
+ ;; It is safe to combine the offset and constant here.
+ (i64.store offset=4
+ (i64.const 6)
+ (i64.const 42)
+ )
+ ;; This would overflow, so do not optimize.
+ (f32.store offset=4
+ (i64.const -3)
+ (f32.const 3.14159)
+ )
+ )
+)
+