fixing missing antidependencies

Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
This commit is contained in:
Jakub Doka 2024-12-16 17:37:14 +01:00
parent c0d957e70c
commit 1ca9529302
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
2 changed files with 20 additions and 9 deletions

View file

@ -28,9 +28,11 @@ use {
fmt::{self, Debug, Display, Write}, fmt::{self, Debug, Display, Write},
format_args as fa, mem, format_args as fa, mem,
ops::{self, Range}, ops::{self, Range},
usize,
}, },
hashbrown::hash_map, hashbrown::hash_map,
hbbytecode::DisasmError, hbbytecode::DisasmError,
std::panic,
}; };
pub const VOID: Nid = 0; pub const VOID: Nid = 0;
@ -476,6 +478,7 @@ impl Nodes {
antidep_bounds: &mut Vec<Nid>, antidep_bounds: &mut Vec<Nid>,
) -> Nid { ) -> Nid {
debug_assert!(self[load].kind == Kind::Load); 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]); let (aclass, _) = self.aclass_index(self[load].inputs[1]);
@ -496,6 +499,9 @@ impl Nodes {
match self[out].kind { match self[out].kind {
Kind::Stre => { Kind::Stre => {
let mut cursor = scheds[out as usize]; let mut cursor = scheds[out as usize];
if cursor == scheds[load as usize] {
antidep_bounds.extend([load, out]);
}
while cursor != scheds[load as usize] while cursor != scheds[load as usize]
&& self.idepth(cursor, Some(scheds)) && self.idepth(cursor, Some(scheds))
> self.idepth(scheds[load as usize], Some(scheds)) > self.idepth(scheds[load as usize], Some(scheds))
@ -509,14 +515,19 @@ impl Nodes {
} }
cursor = self.idom(cursor, Some(scheds)); cursor = self.idom(cursor, Some(scheds));
} }
//if out == 110 && load == 108 {
// panic!("{min} {cursor} {}", antideps[cursor as usize] == load)
//}
break; break;
} }
Kind::Phi => { Kind::Phi => {
let n = self[out].inputs[1..] let side = self[out].inputs[1..]
.iter() .iter()
.position(|&n| n == self[load].inputs[2]) .position(|&n| n == self[load].inputs[2])
.unwrap(); .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] while cursor != scheds[load as usize]
&& self.idepth(cursor, Some(scheds)) && self.idepth(cursor, Some(scheds))
> self.idepth(scheds[load as usize], Some(scheds)) > self.idepth(scheds[load as usize], Some(scheds))

View file

@ -151,13 +151,13 @@ push:
CP r32, r33 CP r32, r33
CP r34, r36 CP r34, r36
JMP :7 JMP :7
0: LD r32, r38, 0a, 8h 0: LD r32, r38, 8a, 8h
LD r33, r38, 8a, 8h LD r33, r38, 0a, 8h
ADD64 r32, r33, r32 ADD64 r33, r32, r33
ST r39, r32, 0a, 1h ST r39, r33, 0a, 1h
ADD64 r33, r33, r37 ADD64 r32, r32, r37
ST r33, r38, 8a, 8h ST r32, r38, 8a, 8h
CP r1, r32 CP r1, r33
4: LD r31, r254, 0a, 80h 4: LD r31, r254, 0a, 80h
ADDI64 r254, r254, 80d ADDI64 r254, r254, 80d
JALA r0, r31, 0a JALA r0, r31, 0a