Skip to content

Commit d6b94d4

Browse files
committed
Things the optimizer does not catch
1 parent da672e2 commit d6b94d4

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

tests/compiler/memcpy.optimized.wast

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
(if
1818
(if (result i32)
1919
(tee_local $3
20-
(i32.ne
21-
(get_local $2)
22-
(i32.const 0)
23-
)
20+
(get_local $2)
2421
)
2522
(i32.rem_s
2623
(get_local $1)

tests/compiler/memcpy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function memcpy(dest: usize, src: usize, n: usize): usize {
44
let w: u32, x: u32;
55

66
// copy 1 byte each until src is aligned to 4 bytes
7-
while (n != 0 && s % 4 != 0) {
7+
while (n && s % 4) {
88
store<u8>(d++, load<u8>(s++));
99
n--;
1010
}

tests/compiler/memcpy.wast

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,11 @@
108108
(if
109109
(if (result i32)
110110
(tee_local $7
111-
(i32.ne
112-
(get_local $2)
113-
(i32.const 0)
114-
)
111+
(get_local $2)
115112
)
116-
(i32.ne
117-
(i32.rem_s
118-
(get_local $4)
119-
(i32.const 4)
120-
)
121-
(i32.const 0)
113+
(i32.rem_s
114+
(get_local $4)
115+
(i32.const 4)
122116
)
123117
(get_local $7)
124118
)

0 commit comments

Comments
 (0)