optimizer-bug #14
@@ -18,6 +18,12 @@ mod tests {
|
|||||||
let compiler = Compiler::new(parser, None);
|
let compiler = Compiler::new(parser, None);
|
||||||
let result = compiler.compile();
|
let result = compiler.compile();
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
result.errors.is_empty(),
|
||||||
|
"Compilation errors: {:?}",
|
||||||
|
result.errors
|
||||||
|
);
|
||||||
|
|
||||||
// Get unoptimized output
|
// Get unoptimized output
|
||||||
let mut unoptimized_writer = std::io::BufWriter::new(Vec::new());
|
let mut unoptimized_writer = std::io::BufWriter::new(Vec::new());
|
||||||
result
|
result
|
||||||
@@ -219,4 +225,20 @@ mod tests {
|
|||||||
let output = compile_with_and_without_optimization(source);
|
let output = compile_with_and_without_optimization(source);
|
||||||
insta::assert_snapshot!(output);
|
insta::assert_snapshot!(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_setbatched_with_member_access() {
|
||||||
|
let source = indoc! {r#"
|
||||||
|
const SENSOR = 20088;
|
||||||
|
const PANELS = hash("StructureSolarPanelDual");
|
||||||
|
|
||||||
|
loop {
|
||||||
|
setBatched(PANELS, "Horizontal", SENSOR.Horizontal);
|
||||||
|
setBatched(PANELS, "Vertical", SENSOR.Vertical + 90);
|
||||||
|
yield();
|
||||||
|
}
|
||||||
|
"#};
|
||||||
|
let output = compile_with_and_without_optimization(source);
|
||||||
|
insta::assert_snapshot!(output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
source: libs/integration_tests/src/lib.rs
|
||||||
|
assertion_line: 242
|
||||||
|
expression: output
|
||||||
|
---
|
||||||
|
## Unoptimized Output
|
||||||
|
|
||||||
|
j main
|
||||||
|
main:
|
||||||
|
__internal_L1:
|
||||||
|
l r1 20088 Horizontal
|
||||||
|
sb -539224550 Horizontal r1
|
||||||
|
l r2 20088 Vertical
|
||||||
|
add r3 r2 90
|
||||||
|
sb -539224550 Vertical r3
|
||||||
|
yield
|
||||||
|
j __internal_L1
|
||||||
|
__internal_L2:
|
||||||
|
|
||||||
|
## Optimized Output
|
||||||
|
|
||||||
|
l r1 20088 Horizontal
|
||||||
|
sb -539224550 Horizontal r1
|
||||||
|
l r2 20088 Vertical
|
||||||
|
add r3 r2 90
|
||||||
|
sb -539224550 Vertical r3
|
||||||
|
yield
|
||||||
|
j 0
|
||||||
@@ -125,6 +125,9 @@ pub fn reg_is_read(instr: &Instruction, reg: u8) -> bool {
|
|||||||
| Instruction::Pow(_, a, b) => check(a) || check(b),
|
| Instruction::Pow(_, a, b) => check(a) || check(b),
|
||||||
Instruction::Load(_, a, _) => check(a),
|
Instruction::Load(_, a, _) => check(a),
|
||||||
Instruction::Store(a, _, b) => check(a) || check(b),
|
Instruction::Store(a, _, b) => check(a) || check(b),
|
||||||
|
Instruction::StoreBatch(a, _, b) => check(a) || check(b),
|
||||||
|
Instruction::StoreBatchNamed(a, b, _, c) => check(a) || check(b) || check(c),
|
||||||
|
Instruction::StoreSlot(a, b, _, c) => check(a) || check(b) || check(c),
|
||||||
Instruction::BranchEq(a, b, _)
|
Instruction::BranchEq(a, b, _)
|
||||||
| Instruction::BranchNe(a, b, _)
|
| Instruction::BranchNe(a, b, _)
|
||||||
| Instruction::BranchGt(a, b, _)
|
| Instruction::BranchGt(a, b, _)
|
||||||
@@ -167,6 +170,8 @@ pub fn reg_is_read(instr: &Instruction, reg: u8) -> bool {
|
|||||||
Instruction::Atan2(_, a, b) | Instruction::Max(_, a, b) | Instruction::Min(_, a, b) => {
|
Instruction::Atan2(_, a, b) | Instruction::Max(_, a, b) | Instruction::Min(_, a, b) => {
|
||||||
check(a) || check(b)
|
check(a) || check(b)
|
||||||
}
|
}
|
||||||
|
Instruction::JumpRelative(a) => check(a),
|
||||||
|
Instruction::Alias(_, a) => check(a),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user