In simplify_repeated_aggregate
, don't test first element against itself
This commit is contained in:
parent
1e008dd5d8
commit
5b596cd28b
1 changed files with 3 additions and 3 deletions
|
@ -78,20 +78,20 @@ impl<'tcx> InstSimplifyContext<'_, 'tcx> {
|
||||||
/// GVN can also do this optimization, but GVN is only run at mir-opt-level 2 so having this in
|
/// GVN can also do this optimization, but GVN is only run at mir-opt-level 2 so having this in
|
||||||
/// InstSimplify helps unoptimized builds.
|
/// InstSimplify helps unoptimized builds.
|
||||||
fn simplify_repeated_aggregate(&self, rvalue: &mut Rvalue<'tcx>) {
|
fn simplify_repeated_aggregate(&self, rvalue: &mut Rvalue<'tcx>) {
|
||||||
let Rvalue::Aggregate(box AggregateKind::Array(_), fields) = rvalue else {
|
let Rvalue::Aggregate(box AggregateKind::Array(_), fields) = &*rvalue else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if fields.len() < 5 {
|
if fields.len() < 5 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let first = &fields[rustc_abi::FieldIdx::ZERO];
|
let (first, rest) = fields[..].split_first().unwrap();
|
||||||
let Operand::Constant(first) = first else {
|
let Operand::Constant(first) = first else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let Ok(first_val) = first.const_.eval(self.tcx, self.typing_env, first.span) else {
|
let Ok(first_val) = first.const_.eval(self.tcx, self.typing_env, first.span) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if fields.iter().all(|field| {
|
if rest.iter().all(|field| {
|
||||||
let Operand::Constant(field) = field else {
|
let Operand::Constant(field) = field else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue