Skip to content

Commit 8093f11

Browse files
committed
ignore arrays in operands
1 parent 3b75afe commit 8093f11

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,10 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
816816
}
817817
Operand::Copy(ref mut place) | Operand::Move(ref mut place) => {
818818
let value = self.simplify_place_value(place, location)?;
819+
// Ignore arrays in operand.
820+
if let Value::Aggregate(AggregateTy::Array, ..) = self.get(value) {
821+
return None;
822+
}
819823
if let Some(const_) = self.try_as_constant(value) {
820824
*operand = Operand::Constant(Box::new(const_));
821825
}

tests/mir-opt/const_array_locals.main.GVN.diff

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@
7474
StorageLive(_11);
7575
StorageLive(_12);
7676
- _12 = [const 1f32, const 2f32, const 3f32, const 1f32, const 1f32, const 1f32, const 1f32, const 42f32];
77-
- _11 = F32x8(move _12);
7877
+ _12 = const [1f32, 2f32, 3f32, 1f32, 1f32, 1f32, 1f32, 42f32];
79-
+ _11 = F32x8(const [1f32, 2f32, 3f32, 1f32, 1f32, 1f32, 1f32, 42f32]);
78+
_11 = F32x8(move _12);
8079
StorageDead(_12);
8180
StorageLive(_13);
8281
StorageLive(_14);

0 commit comments

Comments
 (0)