Auto merge of #112638 - lqd:rpo, r=cjgillot
Switch the BB CFG cache from postorder to RPO The `BasicBlocks` CFG cache is interesting: - it stores a postorder, but `traversal::postorder` doesn't use it - `traversal::reverse_postorder` does traverse the postorder cache backwards - we do more RPO traversals than postorder traversals (around 20x on the perf.rlo benchmarks IIRC) but it's not cached - a couple places here and there were manually reversing the non-cached postorder traversal This PR switches the order of the cache, and makes a bit more use of it. This is a tiny win locally, but it's also for consistency and aesthetics. r? `@ghost`
This commit is contained in:
commit
677710eaf0
5 changed files with 31 additions and 46 deletions
|
@ -118,8 +118,8 @@ impl<'tcx> MirPass<'tcx> for ConstProp {
|
|||
|
||||
// Traverse the body in reverse post-order, to ensure that `FullConstProp` locals are
|
||||
// assigned before being read.
|
||||
let postorder = body.basic_blocks.postorder().to_vec();
|
||||
for bb in postorder.into_iter().rev() {
|
||||
let rpo = body.basic_blocks.reverse_postorder().to_vec();
|
||||
for bb in rpo {
|
||||
let data = &mut body.basic_blocks.as_mut_preserves_cfg()[bb];
|
||||
optimization_finder.visit_basic_block_data(bb, data);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ impl<'tcx> MirPass<'tcx> for ReorderBasicBlocks {
|
|||
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
let rpo: IndexVec<BasicBlock, BasicBlock> =
|
||||
body.basic_blocks.postorder().iter().copied().rev().collect();
|
||||
body.basic_blocks.reverse_postorder().iter().copied().collect();
|
||||
if rpo.iter().is_sorted() {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue