1
Fork 0

Rollup merge of #125796 - scottmcm:more-inst-simplify, r=oli-obk

Also InstSimplify `&raw*`

We do this for `&*` and `&mut*` already; might as well do it for raw pointers too.

r? mir-opt
This commit is contained in:
Matthias Krüger 2024-05-31 17:05:25 +02:00 committed by GitHub
commit 234ed6ae5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 157 additions and 1 deletions

View file

@ -123,7 +123,7 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
/// Transform `&(*a)` ==> `a`.
fn simplify_ref_deref(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
if let Rvalue::Ref(_, _, place) = rvalue {
if let Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) = rvalue {
if let Some((base, ProjectionElem::Deref)) = place.as_ref().last_projection() {
if rvalue.ty(self.local_decls, self.tcx) != base.ty(self.local_decls, self.tcx).ty {
return;