0xMiden / 0xMiden/compiler

LoopInfo::has_loops returns true when there are no loops

Offen
#762 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
115
Forks
84
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
15

Beschreibung

In the file hir/src/ir/loops.rs, the function LoopInfo::has_loops
```rust
impl LoopInfo {
/// Returns true if the op this info was derived from contains any loops
pub fn has_loops(&self) -> bool {
!self.per_region.is_empty() && !self.per_region.iter().any(|info| !info.forest.is_empty())
}
}
```

(currently: !self.per_region.is_empty() && !self.per_region.iter().any(|info| !info.forest.is_empty())) returns true when all regions of LoopForest are empty (i.e., there are no loops). This contradicts the doc comment for the method (“Returns true if the op this info was derived from contains any loops”), as well as how the presence of loops is determined in region_has_loops (!info.forest.is_empty()) and the semantics of LoopForest::is_empty() (“no loops”).

Correct: self.per_region.iter().any(|info| !info.forest.is_empty()). This way, the method returns true if there are loops in at least one region; on an empty per_region, .any(...) will return false, which is correct. This aligns the behavior with the documentation and with the logic of region_has_loops.

If you find it useful and worth, could you assing me to solve this if you dont mind?

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.