public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "paulo@matos-sorge.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/59999] [4.9 Regression] Sign extension in loop regression blocks generation of zero overhead loop
Date: Thu, 06 Feb 2014 11:16:00 -0000	[thread overview]
Message-ID: <bug-59999-4-mWPnRhQXDw@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-59999-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #13 from Paulo J. Matos <paulo@matos-sorge.com> ---
(In reply to Richard Biener from comment #12)
> 
> Note that {1, +, 1}_1 is unsigned.  The issue is that while i is short
> i++ is really i = (short)((int) i + 1) and thus only the operation in
> type 'int' is known to not overflow and thus the IV in short _can_
> overflow and the loop can loop infinitely for example for loopCount
> == SHORT_MAX + 1.
> 
> The fix to SCEV analysis was to still be able to analyze the evolution at
> all.
> 
> The testcase is simply very badly written (unsigned short upper bound,
> signed short IV and IV comparison against upper bound in signed int).

I thought any signed operation cannot overflow, independently on its width,
therefore (short) (int + 1) shouldn't overflow.

I agree with you on the testcase, however, that's taken from customer code and
it's even if badly written, it's acceptable C. GCC 4.5.4 generates the scalar
evolution for the integer variable: {1, +, 1}_1 without the casts (therefore a
simple_iv). This allows GCC to use an int for an IV which helps discard the
sign extend in the loop body and later on allows the zero overhead loop being
generated. This case happens again and again and causes serious performance
regression on customer code.


  parent reply	other threads:[~2014-02-06 11:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-30 21:41 [Bug tree-optimization/59999] New: " paulo@matos-sorge.com
2014-01-31 10:08 ` [Bug tree-optimization/59999] [4.9 Regression] " rguenth at gcc dot gnu.org
2014-01-31 10:14 ` paulo@matos-sorge.com
2014-01-31 11:41 ` [Bug rtl-optimization/59999] " rguenth at gcc dot gnu.org
2014-01-31 12:04 ` paulo@matos-sorge.com
2014-01-31 14:52 ` rguenth at gcc dot gnu.org
2014-01-31 15:09 ` paulo@matos-sorge.com
2014-02-05 11:03 ` paulo@matos-sorge.com
2014-02-05 12:14 ` paulo@matos-sorge.com
2014-02-05 12:15 ` paulo@matos-sorge.com
2014-02-05 15:37 ` paulo@matos-sorge.com
2014-02-05 17:09 ` paulo@matos-sorge.com
2014-02-06 10:28 ` rguenth at gcc dot gnu.org
2014-02-06 11:16 ` paulo@matos-sorge.com [this message]
2014-02-06 11:25 ` paulo@matos-sorge.com
2014-02-06 12:05 ` rguenther at suse dot de
2014-02-06 12:40 ` paulo@matos-sorge.com
2014-02-06 13:04 ` paulo@matos-sorge.com
2014-02-06 13:17 ` rguenther at suse dot de
2014-02-06 13:20 ` rguenther at suse dot de
2014-02-07 10:08 ` paulo@matos-sorge.com
2014-02-07 11:01 ` rguenther at suse dot de
2014-02-12 13:03 ` paulo@matos-sorge.com
2014-02-12 13:30 ` rguenther at suse dot de
2014-02-12 13:39 ` pmatos 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-59999-4-mWPnRhQXDw@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).