diff --git a/lang/src/son.rs b/lang/src/son.rs index a6b8fb35..d0e7dcb6 100644 --- a/lang/src/son.rs +++ b/lang/src/son.rs @@ -28,9 +28,11 @@ use { fmt::{self, Debug, Display, Write}, format_args as fa, mem, ops::{self, Range}, + usize, }, hashbrown::hash_map, hbbytecode::DisasmError, + std::panic, }; pub const VOID: Nid = 0; @@ -476,6 +478,7 @@ impl Nodes { antidep_bounds: &mut Vec, ) -> Nid { debug_assert!(self[load].kind == Kind::Load); + debug_assert!(self.dominates(scheds[load as usize], min, Some(scheds)), "{load}"); let (aclass, _) = self.aclass_index(self[load].inputs[1]); @@ -496,6 +499,9 @@ impl Nodes { match self[out].kind { Kind::Stre => { let mut cursor = scheds[out as usize]; + if cursor == scheds[load as usize] { + antidep_bounds.extend([load, out]); + } while cursor != scheds[load as usize] && self.idepth(cursor, Some(scheds)) > self.idepth(scheds[load as usize], Some(scheds)) @@ -509,14 +515,19 @@ impl Nodes { } cursor = self.idom(cursor, Some(scheds)); } + + //if out == 110 && load == 108 { + // panic!("{min} {cursor} {}", antideps[cursor as usize] == load) + //} break; } Kind::Phi => { - let n = self[out].inputs[1..] + let side = self[out].inputs[1..] .iter() .position(|&n| n == self[load].inputs[2]) .unwrap(); - let mut cursor = self[self[out].inputs[0]].inputs[n]; + let ctrl = self[out].inputs[0]; + let mut cursor = self[ctrl].inputs[side]; while cursor != scheds[load as usize] && self.idepth(cursor, Some(scheds)) > self.idepth(scheds[load as usize], Some(scheds)) diff --git a/lang/tests/son_tests_generic_types.txt b/lang/tests/son_tests_generic_types.txt index e8939554..7318f32f 100644 --- a/lang/tests/son_tests_generic_types.txt +++ b/lang/tests/son_tests_generic_types.txt @@ -151,13 +151,13 @@ push: CP r32, r33 CP r34, r36 JMP :7 - 0: LD r32, r38, 0a, 8h - LD r33, r38, 8a, 8h - ADD64 r32, r33, r32 - ST r39, r32, 0a, 1h - ADD64 r33, r33, r37 - ST r33, r38, 8a, 8h - CP r1, r32 + 0: LD r32, r38, 8a, 8h + LD r33, r38, 0a, 8h + ADD64 r33, r32, r33 + ST r39, r33, 0a, 1h + ADD64 r32, r32, r37 + ST r32, r38, 8a, 8h + CP r1, r33 4: LD r31, r254, 0a, 80h ADDI64 r254, r254, 80d JALA r0, r31, 0a