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/55022] [4.8/4.9 Regression] air.f90 is miscompliled with -m64 -O2 -fgraphite-identity after revision 190619
Date: Fri, 11 Apr 2014 11:28:00 -0000	[thread overview]
Message-ID: <bug-55022-4-TPmUBsj4sA@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55022-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #20 from rguenther at suse dot de <rguenther at suse dot de> ---
On Fri, 11 Apr 2014, kargov at gmail dot com wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55022
> 
> --- Comment #19 from Vladimir Kargov <kargov at gmail dot com> ---
> > if you are refering to negate_expr () negating a /[fl] CST as a /[fl] -CST
> then yes, that looks suspicious
> Yes, the one.
> 
> The function converts expressions "x * -C" into "-x * C". In the case where x
> is an expression of form "a /[fl] b" or "a /[cl] b" this optimization is
> generally invalid. For example:
> (1 /[fl] 2) * -1 = 0 * -1 = 0 will turn into (1 /[fl] -2) * 1 = -1 * 1 = -1
> (1 /[cl] 2) * -1 = 1 * -1 = -1 will turn into (1 /[cl] -2) * 1 = 0 * 1 = 0
> In general, it appears that the optimization will be incorrect for any floor
> and ceiling divisions with a non-zero remainder since after negation they will
> be rounded to a different integer.
> 
> The problem can be seen in the following function when compiled with "-O3
> -fgraphite-identity":
> 
> void f(int *limit, int minLen, int maxLen)
> {
>   int i;
> 
>   for (i = minLen; i <= maxLen; i++) {
>     limit[i] = i;
>   }
> }
> 
> In this case constant folding will be transforming expression "(((signed long)
> maxLen_5(D) - (signed long) minLen_3(D)) /[fl] 4294967296) * -1" (i.e. 0) into
> "((signed long) maxLen_5(D) - (signed long) minLen_3(D)) /[fl] -4294967296"
> (i.e. -4294967296).
> 
> Since Graphite abundantly uses floor division, this breaks a lot of code,
> including bzip2 build
> (https://groups.google.com/forum/#!topic/gcc-graphite/WaCUu0xg4Kc) and this
> bug.
> 
> Removing floor and ceiling division as in comment 18 will fix it.

I can't seem to observe the above with the testcase or sth like
the following suitable for the testsuite:

/* { dg-do run } */
/* { dg-options "-O3 -fgraphite-identity" } */

extern void abort (void);

void __attribute__((noinline,noclone))
f(int *limit, int minLen, int maxLen)
{
  int i;

  for (i = minLen; i <= maxLen; i++) {
      limit[i] = i;
  }
}

int main()
{
  int limit[256], i;
  f (limit, 0, 255);
  for (i = 0; i < 256; ++i)
    {
      if (limit[i] != i)
        abort ();
      __asm__ volatile ("" : : : "memory");
    }
  return 0;
}


  parent reply	other threads:[~2014-04-11 11:28 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-22 13:53 [Bug tree-optimization/55022] New: [4.8 " dominiq at lps dot ens.fr
2012-10-22 14:25 ` [Bug tree-optimization/55022] " dominiq at lps dot ens.fr
2012-10-23 13:36 ` dominiq at lps dot ens.fr
2012-11-25 15:52 ` rguenth at gcc dot gnu.org
2013-01-04  3:11 ` pinskia at gcc dot gnu.org
2013-01-04  7:29 ` dominiq at lps dot ens.fr
2013-02-05 15:58 ` aldyh at gcc dot gnu.org
2013-02-05 16:01 ` dominiq at lps dot ens.fr
2013-02-05 16:11 ` grosser at gcc dot gnu.org
2013-02-05 23:52 ` aldyh at gcc dot gnu.org
2013-02-06 18:19 ` aldyh at gcc dot gnu.org
2013-02-06 21:08 ` aldyh at gcc dot gnu.org
2013-02-07 14:58 ` dominiq at lps dot ens.fr
2013-02-07 15:11 ` dominiq at lps dot ens.fr
2013-02-20 13:59 ` rguenth at gcc dot gnu.org
2013-03-22 14:42 ` [Bug tree-optimization/55022] [4.8/4.9 " jakub at gcc dot gnu.org
2013-05-31 10:57 ` jakub at gcc dot gnu.org
2013-10-16  9:48 ` jakub at gcc dot gnu.org
2014-01-17 12:34 ` rguenth at gcc dot gnu.org
2014-04-10 16:01 ` mircea.namolaru at inria dot fr
2014-04-11 11:02 ` rguenth at gcc dot gnu.org
2014-04-11 11:10 ` kargov at gmail dot com
2014-04-11 11:28 ` rguenther at suse dot de [this message]
2014-04-11 11:32 ` kargov at gmail dot com
2014-04-11 11:33 ` rguenth at gcc dot gnu.org
2014-04-11 11:43 ` kargov at gmail dot com
2014-04-11 13:03 ` kargov at gmail dot com
2014-04-14  8:11 ` [Bug tree-optimization/55022] [4.8/4.9/4.10 " rguenth at gcc dot gnu.org
2014-04-22 13:34 ` [Bug tree-optimization/55022] [4.8 " rguenth at gcc dot gnu.org
2014-04-23  8:58 ` mircea.namolaru at inria dot fr
2014-05-06 12:01 ` rguenth at gcc dot gnu.org
2014-05-06 12:02 ` 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-55022-4-TPmUBsj4sA@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).