Skip to content

Commit

Permalink
fix optimizer bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ckrause committed Sep 13, 2024
1 parent e50048f commit 86ef769
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ To install or update LODA, please follow the [installation instructions](https:/

## [Unreleased]

### Bugfixes

* Fix optimizer bug

## v24.9.7

### Bugfixes
Expand Down
5 changes: 0 additions & 5 deletions src/eval/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,11 +793,6 @@ bool Optimizer::collapseMovLoops(Program &p) const {
if (val < Number::ZERO) {
p.ops.erase(p.ops.begin() + i, p.ops.begin() + i + 3);
changed = true;
} else if (val == Number::ZERO) {
p.ops.erase(p.ops.begin() + i + 1, p.ops.begin() + i + 3);
p.ops[i] = Operation(Operation::Type::MOV, lpb.target,
Operand(Operand::Type::CONSTANT, 0));
changed = true;
} else {
p.ops.erase(p.ops.begin() + i + 1, p.ops.begin() + i + 3);
p.ops[i] = Operation(Operation::Type::MIN, lpb.target,
Expand Down
4 changes: 3 additions & 1 deletion tests/optimizer/E047.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ lpb $0
lpe
add $0,7
; out
mov $0,7
add $0,3
min $0,0
add $0,7
10 changes: 10 additions & 0 deletions tests/optimizer/E049.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; in
sub $0,3
lpb $0
mov $0,0
lpe
sub $0,7
; out
sub $0,3
min $0,0
sub $0,7

0 comments on commit 86ef769

Please sign in to comment.