summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/passes/MemoryPacking.cpp7
-rw-r--r--test/passes/memory-packing_all-features.txt5
2 files changed, 10 insertions, 2 deletions
diff --git a/src/passes/MemoryPacking.cpp b/src/passes/MemoryPacking.cpp
index 18207026a..98c7cce00 100644
--- a/src/passes/MemoryPacking.cpp
+++ b/src/passes/MemoryPacking.cpp
@@ -140,7 +140,12 @@ struct MemoryPacking : public Pass {
builder.makeBinary(
OrInt32,
builder.makeBinary(
- GtUInt32, curr->dest, builder.makeHost(MemorySize, Name(), {})),
+ GtUInt32,
+ curr->dest,
+ builder.makeBinary(
+ MulInt32,
+ builder.makeConst(Literal(Memory::kPageSize)),
+ builder.makeHost(MemorySize, Name(), {}))),
builder.makeBinary(OrInt32, curr->offset, curr->size)),
builder.makeUnreachable()));
changed = true;
diff --git a/test/passes/memory-packing_all-features.txt b/test/passes/memory-packing_all-features.txt
index 5f6c5dacc..9b2eaad29 100644
--- a/test/passes/memory-packing_all-features.txt
+++ b/test/passes/memory-packing_all-features.txt
@@ -26,7 +26,10 @@
(i32.or
(i32.gt_u
(i32.const 0)
- (memory.size)
+ (i32.mul
+ (i32.const 65536)
+ (memory.size)
+ )
)
(i32.or
(i32.const 0)