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

View file

@ -41,8 +41,9 @@
bb1: {
- _6 = _3[_7];
+ _6 = _3[0 of 1];
_5 = opaque::<T>(move _6) -> [return: bb2, unwind unreachable];
- _5 = opaque::<T>(move _6) -> [return: bb2, unwind unreachable];
+ _6 = _1;
+ _5 = opaque::<T>(_1) -> [return: bb2, unwind unreachable];
}
bb2: {
@ -63,8 +64,9 @@
bb3: {
- _11 = _3[_12];
+ _11 = _3[_2];
_10 = opaque::<T>(move _11) -> [return: bb4, unwind unreachable];
- _10 = opaque::<T>(move _11) -> [return: bb4, unwind unreachable];
+ _11 = _1;
+ _10 = opaque::<T>(_1) -> [return: bb4, unwind unreachable];
}
bb4: {

View file

@ -41,8 +41,9 @@
bb1: {
- _6 = _3[_7];
+ _6 = _3[0 of 1];
_5 = opaque::<T>(move _6) -> [return: bb2, unwind continue];
- _5 = opaque::<T>(move _6) -> [return: bb2, unwind continue];
+ _6 = _1;
+ _5 = opaque::<T>(_1) -> [return: bb2, unwind continue];
}
bb2: {
@ -63,8 +64,9 @@
bb3: {
- _11 = _3[_12];
+ _11 = _3[_2];
_10 = opaque::<T>(move _11) -> [return: bb4, unwind continue];
- _10 = opaque::<T>(move _11) -> [return: bb4, unwind continue];
+ _11 = _1;
+ _10 = opaque::<T>(_1) -> [return: bb4, unwind continue];
}
bb4: {