Skip process_constant if state has no matching value.

This commit is contained in:
Camille GILLOT 2025-06-22 08:38:50 +00:00 committed by Camille Gillot
parent f12ab2790d
commit acf3b6a6a6
2 changed files with 11 additions and 3 deletions

View file

@ -750,11 +750,15 @@ impl<'tcx> Map<'tcx> {
}
}
/// Return the range of value indices inside this place.
pub fn values_inside(&self, root: PlaceIndex) -> &[ValueIndex] {
let range = self.inner_values[root].clone();
&self.inner_values_buffer[range]
}
/// Invoke a function on each value in the given place and all descendants.
fn for_each_value_inside(&self, root: PlaceIndex, f: &mut impl FnMut(ValueIndex)) {
let range = self.inner_values[root].clone();
let values = &self.inner_values_buffer[range];
for &v in values {
for &v in self.values_inside(root) {
f(v)
}
}

View file

@ -422,6 +422,10 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> {
constant: OpTy<'tcx>,
state: &mut ConditionSet<'a>,
) {
let values_inside = self.map.values_inside(lhs);
if !state.iter().any(|cond| values_inside.contains(&cond.place)) {
return;
}
self.map.for_each_projection_value(
lhs,
constant,