public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/55216] New: Infinite loop generated on non-infinite code
@ 2012-11-05 18:27 josh.m.conner at gmail dot com
  2012-11-05 18:58 ` [Bug tree-optimization/55216] [4.8 Regression] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: josh.m.conner at gmail dot com @ 2012-11-05 18:27 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55216
           Summary: Infinite loop generated on non-infinite code
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: josh.m.conner@gmail.com


Attempting to compile this code:


  int d[16];

  int
  SATD (void)
  {
    int k, satd = 0, dd;

    for (dd=d[k=0]; k<16; dd=d[++k])
    {
      satd += (dd < 0 ? -dd : dd);
    }

    return satd;
  }

with -O2 generates an infinite loop:


  .L2:
    b    .L2

I am using trunk gcc (sync'd to r193173) configured with:

  --target=arm-linux-gnueabi --with-cpu=cortex-a15 --with-gnu-as --with-gnu-ld
--enable-__cxa_atexit --disable-libssp --disable-libmudflap
--enable-languages=c,c++,fortran --disable-nls

Although I am pretty sure this is a tree optimization issue and not a target
issue because I see the transformation from a valid loop into an invalid loop
during vrp1.

Specifically, when visiting this PHI node for the last time:

  Visiting PHI node: k_1 = PHI <0(2), k_8(4)>

      Argument #0 (2 -> 3 executable)
          0
          Value: [0, 0]

      Argument #1 (4 -> 3 executable)
          k_8
          Value: [1, 15]

vrp_visit_phi_node determines that the range for k_1 is:

  k_1: [0,14]

If I'm understanding this correctly, the union of these ranges should give us
[0,15] instead (and would, except that adjust_range_with_scev() overrides it). 
This invalid range leads to the belief that the loop exit condition can never
be met.


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

* [Bug tree-optimization/55216] [4.8 Regression] Infinite loop generated on non-infinite code
  2012-11-05 18:27 [Bug tree-optimization/55216] New: Infinite loop generated on non-infinite code josh.m.conner at gmail dot com
@ 2012-11-05 18:58 ` pinskia at gcc dot gnu.org
  2012-11-05 19:22 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-11-05 18:58 UTC (permalink / raw)
  To: gcc-bugs


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.8.0
            Summary|Infinite loop generated on  |[4.8 Regression] Infinite
                   |non-infinite code           |loop generated on
                   |                            |non-infinite code


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

* [Bug tree-optimization/55216] [4.8 Regression] Infinite loop generated on non-infinite code
  2012-11-05 18:27 [Bug tree-optimization/55216] New: Infinite loop generated on non-infinite code josh.m.conner at gmail dot com
  2012-11-05 18:58 ` [Bug tree-optimization/55216] [4.8 Regression] " pinskia at gcc dot gnu.org
@ 2012-11-05 19:22 ` pinskia at gcc dot gnu.org
  2012-11-06 15:05 ` amonakov at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-11-05 19:22 UTC (permalink / raw)
  To: gcc-bugs


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-11-05
     Ever Confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-11-05 19:22:38 UTC ---
Confirmed.


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

* [Bug tree-optimization/55216] [4.8 Regression] Infinite loop generated on non-infinite code
  2012-11-05 18:27 [Bug tree-optimization/55216] New: Infinite loop generated on non-infinite code josh.m.conner at gmail dot com
  2012-11-05 18:58 ` [Bug tree-optimization/55216] [4.8 Regression] " pinskia at gcc dot gnu.org
  2012-11-05 19:22 ` pinskia at gcc dot gnu.org
@ 2012-11-06 15:05 ` amonakov at gcc dot gnu.org
  2012-11-06 15:07 ` amonakov at gcc dot gnu.org
  2012-11-08 10:42 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: amonakov at gcc dot gnu.org @ 2012-11-06 15:05 UTC (permalink / raw)
  To: gcc-bugs


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

Alexander Monakov <amonakov at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |amonakov at gcc dot gnu.org
         Resolution|                            |INVALID

--- Comment #2 from Alexander Monakov <amonakov at gcc dot gnu.org> 2012-11-06 15:05:40 UTC ---
The code invokes undefined behavior and is invalid: accessing d[++k] implies
that modified k is less than 16 (because maximum valid index of d is 15), and
therefore loop test (k < 16) is always true.

Enhancement request to produce a warning is filed as PR 52365.


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

* [Bug tree-optimization/55216] [4.8 Regression] Infinite loop generated on non-infinite code
  2012-11-05 18:27 [Bug tree-optimization/55216] New: Infinite loop generated on non-infinite code josh.m.conner at gmail dot com
                   ` (2 preceding siblings ...)
  2012-11-06 15:05 ` amonakov at gcc dot gnu.org
@ 2012-11-06 15:07 ` amonakov at gcc dot gnu.org
  2012-11-08 10:42 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: amonakov at gcc dot gnu.org @ 2012-11-06 15:07 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from Alexander Monakov <amonakov at gcc dot gnu.org> 2012-11-06 15:06:50 UTC ---
> Enhancement request to produce a warning is filed as PR 52365.

Correction: PR 53265.


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

* [Bug tree-optimization/55216] [4.8 Regression] Infinite loop generated on non-infinite code
  2012-11-05 18:27 [Bug tree-optimization/55216] New: Infinite loop generated on non-infinite code josh.m.conner at gmail dot com
                   ` (3 preceding siblings ...)
  2012-11-06 15:07 ` amonakov at gcc dot gnu.org
@ 2012-11-08 10:42 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-11-08 10:42 UTC (permalink / raw)
  To: gcc-bugs


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |DUPLICATE

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-11-08 10:42:25 UTC ---
Oh and this was a dup of bug 53073 which has the fix for the source.  Note
someone if not already should report this to SPEC.

*** This bug has been marked as a duplicate of bug 53073 ***


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

end of thread, other threads:[~2012-11-08 10:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-05 18:27 [Bug tree-optimization/55216] New: Infinite loop generated on non-infinite code josh.m.conner at gmail dot com
2012-11-05 18:58 ` [Bug tree-optimization/55216] [4.8 Regression] " pinskia at gcc dot gnu.org
2012-11-05 19:22 ` pinskia at gcc dot gnu.org
2012-11-06 15:05 ` amonakov at gcc dot gnu.org
2012-11-06 15:07 ` amonakov at gcc dot gnu.org
2012-11-08 10:42 ` pinskia at gcc dot gnu.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).