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 tree-optimization/53128] [4.8 Regression] Compiler produces infinite loop on regular O2
Date: Mon, 07 May 2012 08:52:00 -0000	[thread overview]
Message-ID: <bug-53128-4-mNgJ8fm5HX@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-53128-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from rguenther at suse dot de <rguenther at suse dot de> 2012-05-07 08:43:24 UTC ---
On Fri, 4 May 2012, manu at gcc dot gnu.org wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53128
> 
> --- Comment #7 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-05-04 16:15:09 UTC ---
> (In reply to comment #6)
> > Compiler does not simply see such code, it happens after some analysis, right?
> > For example, after work of infer_loop_bounds_from_undefined which makes some
> > assumptions and I believe can produce some information for user.
> 
> My understanding is that this is non-trivial to do from within the current
> passes because "undefined" in that context does not mean "this code is wrong"
> but "we don't know what happens here but we can assume what doesn't happen". So
> perhaps a new pass looking specifically for infinite loops could be more
> effective.
> 
> In any case, if you know how to do it, please propose a patch, so people can
> discuss it. If there is way to warn for this that doesn't generate an awful
> number of false positives, I think such patch would be very welcome.
> 
> > Again, I'm worrying about all this from user-perspective and especially after
> > discovering 2 such things in spec2006 sources(PR53086 and PR53073).
> 
> I think there is no discussion about whether GCC would like to have such a
> warning. What is not clear is the best way to do it. So please, test your ideas
> and send a prototype of your patch for discussion. People are more likely to
> give you feedback when there is something concrete to discuss about.

One reason I am not trying hard to avoid these issues at the very moment
is to look for _real_ fallout - thus, wrong-code generation on valid
input.  One option for the 4.8 release is to simply never fold the
("the" - if there is a single one) loop exit test to false from within
VRP.  That does not prevent other passes from eventually generating
code that runs afoul of users expectations (with the bogus input),
but at least the "issues at hand" would be mitigated.

Note that this of course would prevent

  int i;
  for (i = 5; i != 1; ++i)
    ...

from being folded into an infinite loop, too, which happens since
quite some GCC releases (based on undefined signed overflow).  And of
course "deliberate" infinite loops would be less optimized as they
would retain a useless exit comparison.

Not sure if people would like to live with a warning for every
loop exit test that is computed to be always false though.

Btw, can you please open an enhacement bugreport for all of this?


  parent reply	other threads:[~2012-05-07  8:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-26 15:35 [Bug tree-optimization/53128] New: " izamyatin at gmail dot com
2012-04-26 15:58 ` [Bug tree-optimization/53128] " hjl.tools at gmail dot com
2012-04-26 16:21 ` amonakov at gcc dot gnu.org
2012-04-27  8:03 ` rguenther at suse dot de
2012-05-03 11:10 ` izamyatin at gmail dot com
2012-05-03 16:03 ` manu at gcc dot gnu.org
2012-05-04 13:19 ` izamyatin at gmail dot com
2012-05-04 16:16 ` manu at gcc dot gnu.org
2012-05-07  8:52 ` rguenther at suse dot de [this message]
2012-05-07 14:11 ` amonakov 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-53128-4-mNgJ8fm5HX@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).