From: Jakub Jelinek Date: Tue, 4 Jan 2022 09:12:17 +0000 (+0100) Subject: shrink-wrapping: Don't call can_get_prologue unnecessarily [PR103860] X-Git-Tag: upstream/12.2.0~2495 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=801b2c880c8079934ac186ea1c31f3bf4af5aef3;p=platform%2Fupstream%2Fgcc.git shrink-wrapping: Don't call can_get_prologue unnecessarily [PR103860] On Thu, Dec 30, 2021 at 04:08:25AM -0600, Segher Boessenkool wrote: > > The following simple patch makes sure we call can_get_prologue even after > > the last former iteration when vec is already empty and only break from > > the loop afterwards (and only if the updating of pro done because of > > !can_get_prologue didn't push anything into vec again). During the development of the above patch I've noticed that in many cases we call can_get_prologue often on the same pro again and again and again, we can have many basic blocks pushed into vec and if most of those don't require pro updates, i.e. basic_block bb = vec.pop (); if (!can_dup_for_shrink_wrapping (bb, pro, max_grow_size)) while (!dominated_by_p (CDI_DOMINATORS, bb, pro)) isn't true, then pro is can_get_prologue checked for each bb in the vec. The following simple patch just remembers which bb we've verified already and verifies again only when pro changes. Most of the patch is just reindentation. 2022-01-04 Jakub Jelinek PR rtl-optimization/103860 * shrink-wrap.c (try_shrink_wrapping): Don't call can_get_prologue uselessly for blocks for which it has been called already. --- diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c index 66b6890..f022039 100644 --- a/gcc/shrink-wrap.c +++ b/gcc/shrink-wrap.c @@ -781,14 +781,20 @@ try_shrink_wrapping (edge *entry_edge, rtx_insn *prologue_seq) unsigned max_grow_size = get_uncond_jump_length (); max_grow_size *= param_max_grow_copy_bb_insns; + basic_block checked_pro = NULL; + while (pro != entry) { - while (pro != entry && !can_get_prologue (pro, prologue_clobbered)) + if (pro != checked_pro) { - pro = get_immediate_dominator (CDI_DOMINATORS, pro); + while (pro != entry && !can_get_prologue (pro, prologue_clobbered)) + { + pro = get_immediate_dominator (CDI_DOMINATORS, pro); - if (bitmap_set_bit (bb_with, pro->index)) - vec.quick_push (pro); + if (bitmap_set_bit (bb_with, pro->index)) + vec.quick_push (pro); + } + checked_pro = pro; } if (vec.is_empty ())