public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/31130]  New: [4.3 Regression] VRP no longer derives range for division after negation
@ 2007-03-11 11:43 rguenth at gcc dot gnu dot org
  2007-03-11 20:40 ` [Bug tree-optimization/31130] " ian at airs dot com
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-03-11 11:43 UTC (permalink / raw)
  To: gcc-bugs

extern void link_error ();
void foo (int a)
{
  if (a < 0)
    {
      int y;
      a = -a;
      y  = a / 7;
      if (y > 1 << 30)
        link_error ();
    }
}

int main()
{
  return 0;
}

Before the VRP overflow handling changes we have after the first VRP pass:

Value ranges after VRP:

a_1(D): VARYING
a_2: [1, +INF]  EQUIVALENCES: { } (0 elements)
y_3: [0, 306783378]  EQUIVALENCES: { } (0 elements)
a_4: [-INF, -1]  EQUIVALENCES: { a_1(D) } (1 elements)

Substituing values and folding statements

Folding predicate y_3 > 1073741824 to 0
Folded statement: if (y_3 > 1073741824) goto <L1>; else goto <L2>;
            into: if (0) goto <L1>; else goto <L2>;

void foo(int) (a)
{
  int y;

<bb 2>:
  if (a_1(D) < 0) goto <L0>; else goto <L2>;

<L0>:;
  a_2 = -a_1(D);
  y_3 = a_2 / 7;

<L2>:;
  return;

}


while now we get

Value ranges after VRP:

a_1(D): VARYING
a_2: [1, +INF(OVF)]  EQUIVALENCES: { } (0 elements)
y_3: [0, +INF(OVF)]  EQUIVALENCES: { } (0 elements)
a_4: [-INF, -1]  EQUIVALENCES: { a_1(D) } (1 elements)

Substituing values and folding statements

foo (a)
{
  int y;

<bb 2>:
  if (a_1(D) < 0) goto <L0>; else goto <L2>;

<L0>:;
  a_2 = -a_1(D);
  y_3 = a_2 / 7;
  if (y_3 > 1073741824) goto <L1>; else goto <L2>;

<L1>:;
  link_error ();

<L2>:;
  return;

}


without -Wstrict-overflow=N warning about the issues with signed negation
and the [1, +INF(OVF)] derived range.  Note that the testcase is simple
enough that expansion optimizes the comparison, so it will not fail to link.


-- 
           Summary: [4.3 Regression] VRP no longer derives range for
                    division after negation
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2010-05-22 18:18 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-11 11:43 [Bug tree-optimization/31130] New: [4.3 Regression] VRP no longer derives range for division after negation rguenth at gcc dot gnu dot org
2007-03-11 20:40 ` [Bug tree-optimization/31130] " ian at airs dot com
2007-03-12  5:43 ` pinskia at gcc dot gnu dot org
2007-03-12  6:12 ` pinskia at gcc dot gnu dot org
2007-03-12 17:08 ` ian at airs dot com
2007-03-12 17:22 ` ian at airs dot com
2007-03-13  9:30 ` rguenth at gcc dot gnu dot org
2007-04-28  0:41 ` [Bug tree-optimization/31130] [4.2/4.3 " pinskia at gcc dot gnu dot org
2007-04-28  4:26 ` ian at airs dot com
2007-04-28  8:56 ` steven at gcc dot gnu dot org
2007-04-30 18:51 ` mmitchel at gcc dot gnu dot org
2007-05-14 21:30 ` mmitchel at gcc dot gnu dot org
2007-07-20  3:50 ` mmitchel at gcc dot gnu dot org
2007-10-09 19:28 ` mmitchel at gcc dot gnu dot org
2008-02-01 17:00 ` jsm28 at gcc dot gnu dot org
2008-05-19 20:30 ` [Bug tree-optimization/31130] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
2009-01-01 21:37 ` pinskia at gcc dot gnu dot org
2009-01-04  4:21 ` ian at airs dot com
2009-03-31 20:07 ` [Bug tree-optimization/31130] [4.3/4.4/4.5 " jsm28 at gcc dot gnu dot org
2009-08-04 12:35 ` rguenth at gcc dot gnu dot org
2010-05-22 18:18 ` [Bug tree-optimization/31130] [4.3/4.4/4.5/4.6 " rguenth at gcc dot gnu dot org

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).