diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-07-26 07:14:44 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-26 07:14:44 +0900 |
| commit | 29892759f6a712b341b35fa66ae485dbe348616f (patch) | |
| tree | f280fdcbe9f88eccf83b8fbabc33160ccda142ae /compiler/rustc_codegen_ssa/src | |
| parent | c1647e10adb688cb9e5bb069946daa969d48f326 (diff) | |
| parent | 9f00d836af0a02110a0a47f4d4c7c7182f04574f (diff) | |
| download | rust-29892759f6a712b341b35fa66ae485dbe348616f.tar.gz rust-29892759f6a712b341b35fa66ae485dbe348616f.zip | |
Rollup merge of #97077 - ouz-a:Optimize-backend, r=oli-obk
Simplify some code that depend on Deref Now that we can assume #97025 works, it's safe to expect Deref is always in the first place of projections. With this, I was able to simplify some code that depended on Deref's place in projections. When we are able to move Derefer before `ElaborateDrops` successfully we will be able to optimize more places. r? `@oli-obk`
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/place.rs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/place.rs b/compiler/rustc_codegen_ssa/src/mir/place.rs index 58cee0c8bb0..268c4d76503 100644 --- a/compiler/rustc_codegen_ssa/src/mir/place.rs +++ b/compiler/rustc_codegen_ssa/src/mir/place.rs @@ -435,18 +435,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { LocalRef::Place(place) => place, LocalRef::UnsizedPlace(place) => bx.load_operand(place).deref(cx), LocalRef::Operand(..) => { - if let Some(elem) = place_ref - .projection - .iter() - .enumerate() - .find(|elem| matches!(elem.1, mir::ProjectionElem::Deref)) - { - base = elem.0 + 1; + if place_ref.has_deref() { + base = 1; let cg_base = self.codegen_consume( bx, - mir::PlaceRef { projection: &place_ref.projection[..elem.0], ..place_ref }, + mir::PlaceRef { projection: &place_ref.projection[..0], ..place_ref }, ); - cg_base.deref(bx.cx()) } else { bug!("using operand local {:?} as place", place_ref); |
