Skip to content

Commit 8709150

Browse files
committed
Improve dead code elimination
1 parent c60c995 commit 8709150

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ binaries are no longer stripped by default.
88
Stripping is now done during linking, rather than shelling out to
99
`strip`. This is faster and more robust.
1010

11+
Improved dead code elimination after multiply loops, e.g. `[>++<-][-]`
12+
is equivalent to `[>++<-]`.
13+
1114
# v1.10.0
1215

1316
Updated to LLVM 13.

src/peephole.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,15 +379,14 @@ fn remove_dead_loops(instrs: Vec<AstNode>) -> Vec<AstNode> {
379379
if let Some(prev_change_index) = previous_cell_change(&instrs, index) {
380380
let prev_instr = &instrs[prev_change_index];
381381
// If the previous instruction set to zero, our loop is dead.
382-
// TODO: MultiplyMove also zeroes the current cell.
383382
// TODO: define an is_set_zero() helper.
384383
if matches!(
385384
prev_instr,
386385
Set {
387386
amount: Wrapping(0),
388387
offset: 0,
389388
..
390-
}
389+
} | MultiplyMove { .. }
391390
) {
392391
return false;
393392
}

0 commit comments

Comments
 (0)