Skip to content

Commit

Permalink
Improve dead code elimination
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfred committed Jun 17, 2023
1 parent c60c995 commit 8709150
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ binaries are no longer stripped by default.
Stripping is now done during linking, rather than shelling out to
`strip`. This is faster and more robust.

Improved dead code elimination after multiply loops, e.g. `[>++<-][-]`
is equivalent to `[>++<-]`.

# v1.10.0

Updated to LLVM 13.
Expand Down
3 changes: 1 addition & 2 deletions src/peephole.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,14 @@ fn remove_dead_loops(instrs: Vec<AstNode>) -> Vec<AstNode> {
if let Some(prev_change_index) = previous_cell_change(&instrs, index) {
let prev_instr = &instrs[prev_change_index];
// If the previous instruction set to zero, our loop is dead.
// TODO: MultiplyMove also zeroes the current cell.
// TODO: define an is_set_zero() helper.
if matches!(
prev_instr,
Set {
amount: Wrapping(0),
offset: 0,
..
}
} | MultiplyMove { .. }
) {
return false;
}
Expand Down

0 comments on commit 8709150

Please sign in to comment.