public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/53695] [4.8 Regression] ICE: in dfs_enumerate_from, at cfganal.c:1221 with -O2 -ftracer and labels/gotos
Date: Thu, 23 Aug 2012 08:07:00 -0000	[thread overview]
Message-ID: <bug-53695-4-9AJuDj72DO@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-53695-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53695

--- Comment #13 from rguenther at suse dot de <rguenther at suse dot de> 2012-08-23 08:07:18 UTC ---
On Thu, 23 Aug 2012, rguenther at suse dot de wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53695
> 
> --- Comment #11 from rguenther at suse dot de <rguenther at suse dot de> 2012-08-23 07:36:46 UTC ---
> On Wed, 22 Aug 2012, steven at gcc dot gnu.org wrote:
> 
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53695
> > 
> > --- Comment #9 from Steven Bosscher <steven at gcc dot gnu.org> 2012-08-22 21:33:18 UTC ---
> > I think the right fix for this bug is to use disambiguate_multiple_latches in
> > the loop updating code (fix_loop_structure), but I'm not sure where to put it.
> 
> Not sure - we can handle multiple latches just fine (loop->latch will
> be NULL).  But I see the loop state does not reflect that.  Maybe
> 
> Index: gcc/cfgloopmanip.c
> ===================================================================
> --- gcc/cfgloopmanip.c  (revision 190613)
> +++ gcc/cfgloopmanip.c  (working copy)
> @@ -1715,6 +1716,9 @@ fix_loop_structure (bitmap changed_bbs)
>         }
>      }
> 
> +  if (!loop_state_satisfies_p (LOOPS_MAY_HAVE_MULTIPLE_LATCHES))
> +    disambiguate_loops_with_multiple_latches ();
> +
>    if (loops_state_satisfies_p (LOOPS_HAVE_PREHEADERS))
>      create_preheaders (CP_SIMPLE_PREHEADERS);
> 
> which matches the order in which loop_optimizer_init calls it.

Doesn't fix the testcase.

We fail during verify_loop_structure and the loop state _does_ have
LOOPS_MAY_HAVE_MULTIPLE_LATCHES set.

Now, for the testcase we at this point just have a single loop
left (we don't recognize the loop with the abnormal path from
header to latch).  Btw, I'm looking at the reduced testcase in
the patch (yes, that's a slightly different situation but simpler
to analyze and fails the same way).  So what's wrong here is
indeed loop->num_nodes (we don't account the other "loop" to
loop 1 and we do not properly mark the loop as having multiple
latches).

Already the input to tracer is "wrong" in that we have "lost"
a loop, the one with abnormal path from latch to header (which
we _do_ reject during loop discovery!).  So what happens is
that we turn this "loop" into one that would have been recognized,
swap header and latch and thus get the abnormal edge to a tolerated
place (header to latch).  That inconsistency is what my patch tries
to address (another way would be to simply allow EH/abnormal
latch -> header edges as well).

So, tracer transforms

 <bb2>
   |
 <bb3>
  | ^
  | |(ab)
  v |
 <bb4> (loop1 header)
  | |                  \
 <bb5> (loop1 latch)    v BB6 -> BB1

by duplicating bb3 to

     <bb2>
       |
     <bb7> (duplicate of bb3)
       |
   ---<bb4> (loop1 header)
(ab) |  / \  \
  |  | <bb5> (loop1 latch)
 <bb3>

but it does not add bb3 to loop1, nor zero out its latch
and setting may-have-multiple-latches.  The cfghook
only takes care of updating the loop structure with
respect to the _new_ basic block but does not consider
that the old one magically becomes part of a loop.

But IMHO the bug is either that we don't consider it
part of the loop before this transform or that we do consider
it part of the loop after the transform!  Which is what
my patch tries to address.

Richard.


  parent reply	other threads:[~2012-08-23  8:07 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-16 11:23 [Bug middle-end/53695] New: " zsojka at seznam dot cz
2012-06-16 16:01 ` [Bug middle-end/53695] " hjl.tools at gmail dot com
2012-06-18  9:03 ` rguenth at gcc dot gnu.org
2012-06-19 14:13 ` rguenth at gcc dot gnu.org
2012-06-27 10:33 ` rguenth at gcc dot gnu.org
2012-08-22  9:37 ` rguenth at gcc dot gnu.org
2012-08-22 19:26 ` steven at gcc dot gnu.org
2012-08-22 20:14 ` steven at gcc dot gnu.org
2012-08-22 20:20 ` steven at gcc dot gnu.org
2012-08-22 21:33 ` steven at gcc dot gnu.org
2012-08-23  7:29 ` rguenther at suse dot de
2012-08-23  7:37 ` rguenther at suse dot de
2012-08-23  7:56 ` stevenb.gcc at gmail dot com
2012-08-23  8:07 ` rguenther at suse dot de [this message]
2012-08-23  8:10 ` rguenther at suse dot de
2012-08-23  8:49 ` stevenb.gcc at gmail dot com
2012-08-23  8:53 ` steven at gcc dot gnu.org
2012-08-23  9:19 ` rguenther at suse dot de
2012-08-23  9:23 ` rguenther at suse dot de
2012-08-23  9:44 ` steven at gcc dot gnu.org
2012-08-23 11:00 ` rguenther at suse dot de
2012-08-23 11:22 ` rguenther at suse dot de
2012-09-19 13:31 ` rguenth at gcc dot gnu.org
2012-10-26 11:58 ` rguenth at gcc dot gnu.org
2012-10-29 14:25 ` rguenth at gcc dot gnu.org
2012-10-29 14:33 ` 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-53695-4-9AJuDj72DO@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).