diff options
| author | bors <bors@rust-lang.org> | 2023-06-27 15:01:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-06-27 15:01:56 +0000 |
| commit | 3c554f5cb4965a08f2a2b45ab4bba321a5f249fa (patch) | |
| tree | f432874eae2a771a43c8a341a9f77aa21eae847a /compiler/rustc_codegen_llvm/src/builder.rs | |
| parent | f42f19b6d3d785a74dbe57aa395b6c288437dd51 (diff) | |
| parent | bd0aae92dc76d9336cf09c097ac5a49fd619da44 (diff) | |
| download | rust-3c554f5cb4965a08f2a2b45ab4bba321a5f249fa.tar.gz rust-3c554f5cb4965a08f2a2b45ab4bba321a5f249fa.zip | |
Auto merge of #112516 - erikdesjardins:loop, r=davidtwco
cg_llvm: use index-based loop in write_operand_repeatedly This should be easier for LLVM to analyze. Fixes #111603 This needs a perf run. [cc](https://github.com/rust-lang/rust/issues/111603#issuecomment-1567531178) `@caojoshua`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/builder.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/builder.rs | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index b4aa001547c..43258078bd7 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -572,8 +572,6 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { ) { let zero = self.const_usize(0); let count = self.const_usize(count); - let start = dest.project_index(self, zero).llval; - let end = dest.project_index(self, count).llval; let header_bb = self.append_sibling_block("repeat_loop_header"); let body_bb = self.append_sibling_block("repeat_loop_body"); @@ -582,24 +580,18 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { self.br(header_bb); let mut header_bx = Self::build(self.cx, header_bb); - let current = header_bx.phi(self.val_ty(start), &[start], &[self.llbb()]); + let i = header_bx.phi(self.val_ty(zero), &[zero], &[self.llbb()]); - let keep_going = header_bx.icmp(IntPredicate::IntNE, current, end); + let keep_going = header_bx.icmp(IntPredicate::IntULT, i, count); header_bx.cond_br(keep_going, body_bb, next_bb); let mut body_bx = Self::build(self.cx, body_bb); - let align = dest.align.restrict_for_offset(dest.layout.field(self.cx(), 0).size); - cg_elem - .val - .store(&mut body_bx, PlaceRef::new_sized_aligned(current, cg_elem.layout, align)); - - let next = body_bx.inbounds_gep( - self.backend_type(cg_elem.layout), - current, - &[self.const_usize(1)], - ); + let dest_elem = dest.project_index(&mut body_bx, i); + cg_elem.val.store(&mut body_bx, dest_elem); + + let next = body_bx.unchecked_uadd(i, self.const_usize(1)); body_bx.br(header_bb); - header_bx.add_incoming_to_phi(current, next, body_bb); + header_bx.add_incoming_to_phi(i, next, body_bb); *self = Self::build(self.cx, next_bb); } |
