public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/100817] ICE with -O2: in compute_antic, at tree-ssa-pre.c:2513
Date: Mon, 31 May 2021 09:32:00 +0000	[thread overview]
Message-ID: <bug-100817-4-ffhSbUw0pI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-100817-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Created attachment 50897
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50897&action=edit
patch

(In reply to Richard Biener from comment #3)
> The number of iterations grows linear with loop depth, starting with 6 for
> 
> for (; a;)
>  for (; a >= 0;)
>   for (; a;)
>    for (; a; a += 2)
>     ;
> 
> adding 2 for every
> 
>  for (; a;)
>   for (; a >= 0;)
> 
> added.  The issue is that the postorder on the inverted graph chosen for
> iteration is "worst" in how it iterates over the loop nest.  Adding an
> exit to the innermost loop makes antic iteration iterate two times
> independent
> on loop depth.  For anti iteration it's important to minimize the number of
> blocks that are visited before all sucessors are visited, but here the whole
> loop nest is only backwards reachable via backedges but there walking the
> nest outer-to-inner producing N such blocks.
> 
> Now, doing reverse program order iteration after the initial postorder
> traversal would fix this, so I'm going to explore this idea.

It's measurably worse for regular CFGs (gcc/*.c), just as example:

 attribs.c.334t.statistics:146 pre "compute_antic iterations == 2" 39
-attribs.c.334t.statistics:146 pre "compute_antic iterations == 3" 27
+attribs.c.334t.statistics:146 pre "compute_antic iterations == 3" 17
+attribs.c.334t.statistics:146 pre "compute_antic iterations == 4" 9
+attribs.c.334t.statistics:146 pre "compute_antic iterations == 5" 1

still only the very first "iteration" technically requires the
postorder on the inverted graph iteration order.  I've attached the patch
I've used for the measurement.

The immediate "fix" would be to remove the assert replacing it with a comment
refering to this PR.  But not sure if action is really required.

  parent reply	other threads:[~2021-05-31  9:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-28 17:24 [Bug c/100817] New: " cnsun at uwaterloo dot ca
2021-05-28 19:24 ` [Bug tree-optimization/100817] " pinskia at gcc dot gnu.org
2021-05-31  6:53 ` rguenth at gcc dot gnu.org
2021-05-31  8:35 ` rguenth at gcc dot gnu.org
2021-05-31  9:32 ` rguenth at gcc dot gnu.org [this message]
2021-06-01  6:34 ` rguenth 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-100817-4-ffhSbUw0pI@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).