Skip to content

Commit 357916d

Browse files
committed
fix assert in intrinsics::mem::replace_element #230
1 parent e939207 commit 357916d

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

codegen/masm/intrinsics/mem.masm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ proc.store_felt_unchecked # [waddr, index, value]
364364
mem_loadw # [w0, w1, w2, w3, waddr, index, value]
365365

366366
# rewrite the desired element
367-
movup.6
368-
movup.5
367+
movup.6 # [value, w0, w1, w2, w3, waddr, index]
368+
movup.6 # [index, value, w0, w1, w2, w3, waddr]
369369
exec.replace_element
370370

371371
# store the updated word

codegen/masm/src/tests.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ fn i32_checked_neg() {
458458
}
459459

460460
#[test]
461-
fn codegen_mem_store_sw() {
461+
fn codegen_mem_store_sw_load_sw() {
462462
const MEMORY_SIZE_BYTES: u32 = 1048576 * 10;
463463
const MEMORY_SIZE_VM_WORDS: u32 = MEMORY_SIZE_BYTES / 16;
464464
let mut harness = TestByEmulationHarness::with_emulator_config(
@@ -516,12 +516,21 @@ fn codegen_mem_store_sw() {
516516
harness.reset();
517517
};
518518

519-
// TODO: on ptr % 4 == 0 load_sw always returns 0
519+
// TODO: seems like on ptr % 4 == 0 load_sw always returns 0
520520
// test(0, 999);
521521
// test(8, 999);
522522
test(1, 42);
523+
test(2, 42);
524+
test(3, 42);
523525
test(25, u32::MAX);
524-
// assert in replace_element fails
526+
// TODO: out of bounds memory access
527+
// test(28, 42);
528+
// ...
529+
// test(31, 42);
530+
//
531+
test(32, 42);
532+
test(33, 42);
533+
test(63, 42);
525534
test(64, 42);
526535
test(MEMORY_SIZE_BYTES - 4, u32::MAX);
527536
}

0 commit comments

Comments
 (0)