fix ice in ssa-range-prop

It used to ICE when hitting an `assert_ne!(location.block, successor.block` due
to hitting a self-dominating bb

Fixed by checking *strict* domination instead of normal one
This commit is contained in:
human9000
2026-04-30 18:49:32 +05:00
parent 7b5afc3bf8
commit d3d6c126d3
2 changed files with 23 additions and 2 deletions
@@ -163,8 +163,7 @@ fn visit_terminator(&mut self, terminator: &mut Terminator<'tcx>, location: Loca
&& self.is_ssa(place) =>
{
let successor = Location { block: *target, statement_index: 0 };
if location.dominates(successor, &self.dominators) {
assert_ne!(location.block, successor.block);
if location.strictly_dominates(successor, &self.dominators) {
let val = *expected as u128;
let range = WrappingRange { start: val, end: val };
self.insert_range(place, successor, range);
@@ -0,0 +1,22 @@
/// Regression test for <https://github.com/rust-lang/rust/issues/155836>.
///
/// SsaRangeProp pass used to fail the assert when encountering self-dominating block
/// e.g. small loops like in `a`
//@ compile-flags: -Copt-level=2
//@ build-pass
use std::hint::black_box;
fn a(d: u8) {
loop {
1 % d;
}
}
pub fn e(d: u8) {
if d == 0 || black_box(false) {
a(d);
}
}
fn main() {
e(1);
}