public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/58227] New: wrong code (hangs) at -O3 on x86_64-linux-gnu
@ 2013-08-23  7:34 su at cs dot ucdavis.edu
  2013-08-23  7:43 ` [Bug tree-optimization/58227] " mpolacek at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-08-23  7:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58227
           Summary: wrong code (hangs) at -O3 on x86_64-linux-gnu
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk produces wrong code (that hangs) for the following
testcase on x86_64-linux when compiled at -O3 in both 32-bit and 64-bit modes. 

This is a regression from 4.8.x.

It might be related to 58143, but 58143 also fails for 4.8. 


$ gcc-trunk -v
gcc version 4.9.0 20130822 (experimental) [trunk revision 201915] (GCC) 
$ gcc-4.8 -O3 reduced.c
$ a.out
$ gcc-trunk -O2 reduced.c
$ a.out
$ gcc-trunk -O3 reduced.c
$ a.out
^C
$ 


------------------------------------------

int a, b, d, e, f, *g, h, i;
volatile int c;

char foo (unsigned char p)
{
  return p + 1;
}

int bar () 
{
  for (h = 0; h < 3; h = foo (h))
    {
      c;
      for (f = 0; f < 1; f++)
    {
      i = a && 0 < -2147483647 - h ? 0 : 1;
      if (e)
        for (; d;)
          b = 0;
      else
        g = 0;
    }
    }
  return 0;
}

int main ()
{
  bar ();
  return 0;
}


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

* [Bug tree-optimization/58227] wrong code (hangs) at -O3 on x86_64-linux-gnu
  2013-08-23  7:34 [Bug tree-optimization/58227] New: wrong code (hangs) at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
@ 2013-08-23  7:43 ` mpolacek at gcc dot gnu.org
  2013-08-23  7:49 ` su at cs dot ucdavis.edu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-08-23  7:43 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I think this invokes undefined behavior in third iteration, when h is 2.  Works
with s/-2147483647/-2147483647L/.


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

* [Bug tree-optimization/58227] wrong code (hangs) at -O3 on x86_64-linux-gnu
  2013-08-23  7:34 [Bug tree-optimization/58227] New: wrong code (hangs) at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
  2013-08-23  7:43 ` [Bug tree-optimization/58227] " mpolacek at gcc dot gnu.org
@ 2013-08-23  7:49 ` su at cs dot ucdavis.edu
  2013-08-23  7:58 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-08-23  7:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Zhendong Su <su at cs dot ucdavis.edu> ---
But similar to 58143, because of short circuiting (since a == 0), the
expression "0 < -2147483647 - h ? 0 : 1" shouldn't be evaluated at all,
correct?  Or maybe I'm mistaken?  

Thanks for looking into this Marek!


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

* [Bug tree-optimization/58227] wrong code (hangs) at -O3 on x86_64-linux-gnu
  2013-08-23  7:34 [Bug tree-optimization/58227] New: wrong code (hangs) at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
  2013-08-23  7:43 ` [Bug tree-optimization/58227] " mpolacek at gcc dot gnu.org
  2013-08-23  7:49 ` su at cs dot ucdavis.edu
@ 2013-08-23  7:58 ` mpolacek at gcc dot gnu.org
  2013-08-23  8:03 ` [Bug tree-optimization/58227] [4.9 Regression] " mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-08-23  7:58 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-08-23
     Ever confirmed|0                           |1

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Yes, sorry.  Loop invariant motion moves the condition here as well, I suppose
(works with -fno-tree-loop-im).  Thus confirmed.


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

* [Bug tree-optimization/58227] [4.9 Regression] wrong code (hangs) at -O3 on x86_64-linux-gnu
  2013-08-23  7:34 [Bug tree-optimization/58227] New: wrong code (hangs) at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (2 preceding siblings ...)
  2013-08-23  7:58 ` mpolacek at gcc dot gnu.org
@ 2013-08-23  8:03 ` mpolacek at gcc dot gnu.org
  2013-08-27 12:00 ` bernd.edlinger at hotmail dot de
  2013-10-15  8:15 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-08-23  8:03 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |4.8.1
   Target Milestone|---                         |4.9.0
            Summary|wrong code (hangs) at -O3   |[4.9 Regression] wrong code
                   |on x86_64-linux-gnu         |(hangs) at -O3 on
                   |                            |x86_64-linux-gnu
      Known to fail|                            |4.9.0


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

* [Bug tree-optimization/58227] [4.9 Regression] wrong code (hangs) at -O3 on x86_64-linux-gnu
  2013-08-23  7:34 [Bug tree-optimization/58227] New: wrong code (hangs) at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (3 preceding siblings ...)
  2013-08-23  8:03 ` [Bug tree-optimization/58227] [4.9 Regression] " mpolacek at gcc dot gnu.org
@ 2013-08-27 12:00 ` bernd.edlinger at hotmail dot de
  2013-10-15  8:15 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2013-08-27 12:00 UTC (permalink / raw)
  To: gcc-bugs

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

Bernd Edlinger <bernd.edlinger at hotmail dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bernd.edlinger at hotmail dot de

--- Comment #4 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
OK, the latest patch from pr58143 seems to fix the deadlock here too.


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

* [Bug tree-optimization/58227] [4.9 Regression] wrong code (hangs) at -O3 on x86_64-linux-gnu
  2013-08-23  7:34 [Bug tree-optimization/58227] New: wrong code (hangs) at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (4 preceding siblings ...)
  2013-08-27 12:00 ` bernd.edlinger at hotmail dot de
@ 2013-10-15  8:15 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-15  8:15 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Duplicate.

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


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

end of thread, other threads:[~2013-10-15  8:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-23  7:34 [Bug tree-optimization/58227] New: wrong code (hangs) at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
2013-08-23  7:43 ` [Bug tree-optimization/58227] " mpolacek at gcc dot gnu.org
2013-08-23  7:49 ` su at cs dot ucdavis.edu
2013-08-23  7:58 ` mpolacek at gcc dot gnu.org
2013-08-23  8:03 ` [Bug tree-optimization/58227] [4.9 Regression] " mpolacek at gcc dot gnu.org
2013-08-27 12:00 ` bernd.edlinger at hotmail dot de
2013-10-15  8:15 ` rguenth 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).