From 1ca9529302e43b7c879fa2cbbecf98aad6361ce5 Mon Sep 17 00:00:00 2001 From: Jakub Doka Date: Mon, 16 Dec 2024 17:37:14 +0100 Subject: [PATCH] fixing missing antidependencies Signed-off-by: Jakub Doka --- lang/src/son.rs | 15 +++++++++++++-- lang/tests/son_tests_generic_types.txt | 14 +++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lang/src/son.rs b/lang/src/son.rs index a6b8fb3..d0e7dcb 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 e893955..7318f32 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