shrink-wrapping: Don't call can_get_prologue unnecessarily [PR103860]
authorJakub Jelinek <jakub@redhat.com>
Tue, 4 Jan 2022 09:12:17 +0000 (10:12 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 4 Jan 2022 09:12:17 +0000 (10:12 +0100)
commit801b2c880c8079934ac186ea1c31f3bf4af5aef3
tree92735cabf5cebdab517a6ddf6bf5bf833abffec7
parent4bd5297f665fd3ba5691297c016809f3501e7fba
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  <jakub@redhat.com>

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.
gcc/shrink-wrap.c