1
Fork 0

Simplify repeat expressions.

This commit is contained in:
Camille GILLOT 2023-09-16 09:36:16 +00:00
parent 48d2157a89
commit f110f22060
3 changed files with 18 additions and 8 deletions

View file

@ -499,11 +499,17 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
ProjectionElem::Field(f, ty)
}
ProjectionElem::Index(idx) => {
if let Value::Repeat(inner, _) = self.get(value) {
return Some(*inner);
}
let idx = self.locals[idx]?;
ProjectionElem::Index(idx)
}
ProjectionElem::ConstantIndex { offset, min_length, from_end } => {
match self.get(value) {
Value::Repeat(inner, _) => {
return Some(*inner);
}
Value::Aggregate(ty, _, operands) if ty.is_array() => {
let offset = if from_end {
operands.len() - offset as usize