public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "aldyh at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/102814] [12 regression] quadratique/exponential time complexity for max-jump-thread-duplication-stmts
Date: Tue, 19 Oct 2021 07:20:53 +0000	[thread overview]
Message-ID: <bug-102814-4-tTTm9dJkmt@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102814-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102814

--- Comment #1 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Dmitry G. Dyachenko from comment #0)
> r12-4256 FAST
> r12-4444 SLOW
> 
> g++ -fpreprocessed -std=c++98 -O2 --param
> max-jump-thread-duplication-stmts=NNN -c x.ii

Well, you are basically eliding the fail safe we put in specifically for this
code explosion:

  /* Threading through an empty latch would cause code to be added to
     the latch.  This could alter the loop form sufficiently to cause
     loop optimizations to fail.  Disable these threads until after
     loop optimizations have run.  */
  if ((threaded_through_latch
       || (taken_edge && taken_edge->dest == loop->latch))
      && !(cfun->curr_properties & PROP_loop_opts_done)
      && empty_block_p (loop->latch))
    {
      if (dump_file && (dump_flags & TDF_DETAILS))
        fprintf (dump_file,
                 "  FAIL: Thread through latch before loop opts would create
non-empty latch\n");
      return false;

The default is 15, and you're pushing it to > 180.  Nothing good can come of
that.

That being said, in this very specific case, thread3 is creating some monster
PHIs which then thread4 further explodes.  Luckily this combination is
disallowed by the pending threading restrictions in the presence of loops here:

https://gcc.gnu.org/pipermail/gcc-patches/2021-October/581894.html

But really, bad things can happen when you disable the fail-safe mechanisms
we've put in place.

Question to the larger audience... do we support bug reports against internal
--param constructs?

  parent reply	other threads:[~2021-10-19  7:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 17:32 [Bug tree-optimization/102814] New: " dimhen at gmail dot com
2021-10-18 21:06 ` [Bug tree-optimization/102814] " pinskia at gcc dot gnu.org
2021-10-19  7:20 ` aldyh at gcc dot gnu.org [this message]
2021-10-19  7:40 ` rguenth at gcc dot gnu.org
2021-10-19  7:45 ` aldyh at gcc dot gnu.org
2021-10-20  7:10 ` aldyh at gcc dot gnu.org
2021-10-20  7:10 ` aldyh at gcc dot gnu.org
2021-10-20  9:09 ` cvs-commit at gcc dot gnu.org
2021-10-20  9:10 ` aldyh at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-102814-4-tTTm9dJkmt@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).