public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/58697] New: wrong code (segfaults) at -O3
@ 2013-10-12  1:17 su at cs dot ucdavis.edu
  2013-10-12 11:33 ` [Bug tree-optimization/58697] [4.8 Regression] " jakub at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: su at cs dot ucdavis.edu @ 2013-10-12  1:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58697
           Summary: wrong code (segfaults) at -O3
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

GCC 4.8.1 miscompiles the following code on x86_64-linux at -O3 in 64-bit mode,
resulting in a segfault. 

It doesn't seem to affect the current trunk and 4.7.x. 

It is related to 58653. 


$ gcc-4.8 -v
Using built-in specs.
COLLECT_GCC=gcc-4.8
COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.8.1/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-checking
--with-gmp=/usr/local/gcc-4.8 --with-mpfr=/usr/local/gcc-4.8
--with-mpc=/usr/local/gcc-4.8 --with-cloog=/usr/local/gcc-4.8
--prefix=/usr/local/gcc-4.8
Thread model: posix
gcc version 4.8.1 (GCC) 
$ 
$
$ gcc-4.8 -O3 small.c; a.out
Segmentation fault (core dumped)
$
$ gcc-trunk -O3 small.c; a.out
$
$ gcc-4.7 -O3 small.c; a.out
$ 


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

int b, f, d[5][2];
unsigned int c;

int
main ()
{
  for (c = 0; c < 2; c++)
    if (d[b + 3][c] & d[b + 4][c])
      if (f)
    break;
  return 0;
}


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

* [Bug tree-optimization/58697] [4.8 Regression] wrong code (segfaults) at -O3
  2013-10-12  1:17 [Bug tree-optimization/58697] New: wrong code (segfaults) at -O3 su at cs dot ucdavis.edu
@ 2013-10-12 11:33 ` jakub at gcc dot gnu.org
  2013-10-14  9:08 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-10-12 11:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-10-12
                 CC|                            |amacleod at redhat dot com,
                   |                            |hubicka at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org
   Target Milestone|---                         |4.8.2
            Summary|wrong code (segfaults) at   |[4.8 Regression] wrong code
                   |-O3                         |(segfaults) at -O3
     Ever confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r192219, ended with r203317.  The latter is weird, I thought
Andrew's patches are just reshuffling of stuff, not changing compiler behavior.
In any case, between r203316 and r203317, pre-unswitch dump the IL is the same,
unswitching is the first changed dump.


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

* [Bug tree-optimization/58697] [4.8 Regression] wrong code (segfaults) at -O3
  2013-10-12  1:17 [Bug tree-optimization/58697] New: wrong code (segfaults) at -O3 su at cs dot ucdavis.edu
  2013-10-12 11:33 ` [Bug tree-optimization/58697] [4.8 Regression] " jakub at gcc dot gnu.org
@ 2013-10-14  9:08 ` rguenth at gcc dot gnu.org
  2013-10-14  9:09 ` [Bug tree-optimization/58697] [4.8/4.9 " rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-14  9:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #1)
> Started with r192219, ended with r203317.  The latter is weird, I thought
> Andrew's patches are just reshuffling of stuff, not changing compiler
> behavior.
> In any case, between r203316 and r203317, pre-unswitch dump the IL is the
> same, unswitching is the first changed dump.

Andrews changes provide accessors that do not compute niter info (you cannot
do that on RTL using the GIMPLE routines).  So if the tree level now uses
those then they need to make sure to compute the info as well.


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

* [Bug tree-optimization/58697] [4.8/4.9 Regression] wrong code (segfaults) at -O3
  2013-10-12  1:17 [Bug tree-optimization/58697] New: wrong code (segfaults) at -O3 su at cs dot ucdavis.edu
  2013-10-12 11:33 ` [Bug tree-optimization/58697] [4.8 Regression] " jakub at gcc dot gnu.org
  2013-10-14  9:08 ` rguenth at gcc dot gnu.org
@ 2013-10-14  9:09 ` rguenth at gcc dot gnu.org
  2013-10-15 18:47 ` amacleod at redhat dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-14  9:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.8 Regression] wrong code |[4.8/4.9 Regression] wrong
                   |(segfaults) at -O3          |code (segfaults) at -O3

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Marking as 4.9 regression so we properly investigate this.


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

* [Bug tree-optimization/58697] [4.8/4.9 Regression] wrong code (segfaults) at -O3
  2013-10-12  1:17 [Bug tree-optimization/58697] New: wrong code (segfaults) at -O3 su at cs dot ucdavis.edu
                   ` (2 preceding siblings ...)
  2013-10-14  9:09 ` [Bug tree-optimization/58697] [4.8/4.9 " rguenth at gcc dot gnu.org
@ 2013-10-15 18:47 ` amacleod at redhat dot com
  2013-10-16  9:50 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: amacleod at redhat dot com @ 2013-10-15 18:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Macleod <amacleod at redhat dot com> ---
Created attachment 31013
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31013&action=edit
patch to re-introduce the error

OK, I found my error :-P  sigh.

estimated_loop_iterations and max_loop_iterations were split into get_ version
for the cfgloop routines.

there are also _int versions of those routines, and
estimated_loop_iterations_int got moved to cfgloop.c.   max_loop_iterations_int
did not.   when estimated_loop_iterations_int got moved, it also was changed to
call get_estimated_loop_iterations like a good cfgroutine.  so when 
tree-ssa-unswitch calls it, it doesn't calculate like it should.

In any case, I think I have the mess sorted out now.  I've added get_ version
for both _int routines as well.  All cfg* routines use 'get_' versions, and all
tree- versions use the non-'get_' version, with the exception of the 2 routines
which actually calculate the values.. they use the get_ version as a fallback
(which is where the factoring came from).

too hard on the head :-)

If I apply this patch, the run time error comes back :-)  seems so backwards
somehow :-)

Anyway, I'm running it through regressions and bootstrapping.


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

* [Bug tree-optimization/58697] [4.8/4.9 Regression] wrong code (segfaults) at -O3
  2013-10-12  1:17 [Bug tree-optimization/58697] New: wrong code (segfaults) at -O3 su at cs dot ucdavis.edu
                   ` (3 preceding siblings ...)
  2013-10-15 18:47 ` amacleod at redhat dot com
@ 2013-10-16  9:50 ` jakub at gcc dot gnu.org
  2013-10-16 15:48 ` amacleod at redhat dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-10-16  9:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.2                       |4.8.3

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.2 has been released.


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

* [Bug tree-optimization/58697] [4.8/4.9 Regression] wrong code (segfaults) at -O3
  2013-10-12  1:17 [Bug tree-optimization/58697] New: wrong code (segfaults) at -O3 su at cs dot ucdavis.edu
                   ` (4 preceding siblings ...)
  2013-10-16  9:50 ` jakub at gcc dot gnu.org
@ 2013-10-16 15:48 ` amacleod at redhat dot com
  2013-11-05 14:59 ` rguenth at gcc dot gnu.org
  2013-11-05 15:32 ` amacleod at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: amacleod at redhat dot com @ 2013-10-16 15:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andrew Macleod <amacleod at redhat dot com> ---
Author: amacleod
Date: Wed Oct 16 15:48:47 2013
New Revision: 203709

URL: http://gcc.gnu.org/viewcvs?rev=203709&root=gcc&view=rev
Log:

    PR tree-optimization/58697
    * cfgloop.c (get_estimated_loop_iterations_int): Rename from 
    estimated_loop_iterations_int.
    (max_stmt_executions_int): Call get_max_loop_iterations_int.
    (get_max_loop_iterations_int): New.  HWINT version of 
    get_max_loop_iterations.
    * cfgloop.h: Add prototypes.
    * loop-iv.c (find_simple_exit): call get_estimated_loop_iterations_int.
    * loop-unroll.c (decide_peel_once_rolling): Call 
    get_estimated_loop_iterations_int.
    * tree-ssa-loop-niter.c (estimated_loop_iterations_int): Add back.
    * tree-ssa-loop-niter.h: Tweak prototypes.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cfgloop.c
    trunk/gcc/cfgloop.h
    trunk/gcc/loop-iv.c
    trunk/gcc/loop-unroll.c
    trunk/gcc/loop-unswitch.c
    trunk/gcc/tree-ssa-loop-niter.c
    trunk/gcc/tree-ssa-loop-niter.h


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

* [Bug tree-optimization/58697] [4.8/4.9 Regression] wrong code (segfaults) at -O3
  2013-10-12  1:17 [Bug tree-optimization/58697] New: wrong code (segfaults) at -O3 su at cs dot ucdavis.edu
                   ` (5 preceding siblings ...)
  2013-10-16 15:48 ` amacleod at redhat dot com
@ 2013-11-05 14:59 ` rguenth at gcc dot gnu.org
  2013-11-05 15:32 ` amacleod at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-11-05 14:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
      Known to fail|                            |4.8.2

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
I still cannot reproduce on trunk but can on the branch.


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

* [Bug tree-optimization/58697] [4.8/4.9 Regression] wrong code (segfaults) at -O3
  2013-10-12  1:17 [Bug tree-optimization/58697] New: wrong code (segfaults) at -O3 su at cs dot ucdavis.edu
                   ` (6 preceding siblings ...)
  2013-11-05 14:59 ` rguenth at gcc dot gnu.org
@ 2013-11-05 15:32 ` amacleod at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: amacleod at redhat dot com @ 2013-11-05 15:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Andrew Macleod <amacleod at redhat dot com> ---
Really? Trunk fails for me this morning.  Works fine at -O2, but I get a
segfault at -O3 on x86_64-unknown-linux-gnu

Andrew


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

end of thread, other threads:[~2013-11-05 15:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-12  1:17 [Bug tree-optimization/58697] New: wrong code (segfaults) at -O3 su at cs dot ucdavis.edu
2013-10-12 11:33 ` [Bug tree-optimization/58697] [4.8 Regression] " jakub at gcc dot gnu.org
2013-10-14  9:08 ` rguenth at gcc dot gnu.org
2013-10-14  9:09 ` [Bug tree-optimization/58697] [4.8/4.9 " rguenth at gcc dot gnu.org
2013-10-15 18:47 ` amacleod at redhat dot com
2013-10-16  9:50 ` jakub at gcc dot gnu.org
2013-10-16 15:48 ` amacleod at redhat dot com
2013-11-05 14:59 ` rguenth at gcc dot gnu.org
2013-11-05 15:32 ` amacleod at redhat dot com

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