public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/28636]  New: [4.0/4.1 regression] Miscompiled loop
@ 2006-08-07 16:34 schwab at suse dot de
  2006-08-07 16:34 ` [Bug middle-end/28636] " schwab at suse dot de
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: schwab at suse dot de @ 2006-08-07 16:34 UTC (permalink / raw)
  To: gcc-bugs

$ gcc -O2 input.c -o input
$ ./input
input: input.c:36: main: Assertion `s.buffer_position == s.buffer_end' failed.

The loop loses the increment of s.buffer_position.


-- 
           Summary: [4.0/4.1 regression] Miscompiled loop
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: schwab at suse dot de
GCC target triplet: ia64-*-*


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


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

* [Bug middle-end/28636] [4.0/4.1 regression] Miscompiled loop
  2006-08-07 16:34 [Bug middle-end/28636] New: [4.0/4.1 regression] Miscompiled loop schwab at suse dot de
@ 2006-08-07 16:34 ` schwab at suse dot de
  2006-08-07 17:34 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: schwab at suse dot de @ 2006-08-07 16:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from schwab at suse dot de  2006-08-07 16:34 -------
Created an attachment (id=12039)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12039&action=view)
Testcase


-- 


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


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

* [Bug middle-end/28636] [4.0/4.1 regression] Miscompiled loop
  2006-08-07 16:34 [Bug middle-end/28636] New: [4.0/4.1 regression] Miscompiled loop schwab at suse dot de
  2006-08-07 16:34 ` [Bug middle-end/28636] " schwab at suse dot de
@ 2006-08-07 17:34 ` pinskia at gcc dot gnu dot org
  2006-08-07 17:51 ` schwab at suse dot de
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-08-07 17:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-08-07 17:34 -------
I bet this is a loop.c bug.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
   Target Milestone|---                         |4.0.4


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


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

* [Bug middle-end/28636] [4.0/4.1 regression] Miscompiled loop
  2006-08-07 16:34 [Bug middle-end/28636] New: [4.0/4.1 regression] Miscompiled loop schwab at suse dot de
  2006-08-07 16:34 ` [Bug middle-end/28636] " schwab at suse dot de
  2006-08-07 17:34 ` pinskia at gcc dot gnu dot org
@ 2006-08-07 17:51 ` schwab at suse dot de
  2006-08-08  0:04 ` schwab at suse dot de
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: schwab at suse dot de @ 2006-08-07 17:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from schwab at suse dot de  2006-08-07 17:51 -------
-floop-optimize2 doesn't help.


-- 


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


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

* [Bug middle-end/28636] [4.0/4.1 regression] Miscompiled loop
  2006-08-07 16:34 [Bug middle-end/28636] New: [4.0/4.1 regression] Miscompiled loop schwab at suse dot de
                   ` (2 preceding siblings ...)
  2006-08-07 17:51 ` schwab at suse dot de
@ 2006-08-08  0:04 ` schwab at suse dot de
  2006-08-08  9:09 ` [Bug rtl-optimization/28636] " rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: schwab at suse dot de @ 2006-08-08  0:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from schwab at suse dot de  2006-08-08 00:04 -------
Looks like introduced during the tree-ssa merge.


-- 


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


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

* [Bug rtl-optimization/28636] [4.0/4.1 regression] Miscompiled loop
  2006-08-07 16:34 [Bug middle-end/28636] New: [4.0/4.1 regression] Miscompiled loop schwab at suse dot de
                   ` (3 preceding siblings ...)
  2006-08-08  0:04 ` schwab at suse dot de
@ 2006-08-08  9:09 ` rguenth at gcc dot gnu dot org
  2006-09-09 22:10 ` ebotcazou at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-08-08  9:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2006-08-08 09:09 -------
Confirmed.  The problem is probably latent on mainline.  check_header is being
miscompiled, -O -fno-loop-optimize2 -fno-loop-optimize -fno-branch-count-reg
is enough to trigger the bug (i.e. no loop bug).

extern void abort(void);
struct input_ty
{
  unsigned char *buffer_position;
  unsigned char *buffer_end;
};
int input_getc_complicated (struct input_ty *x) { return 0; }

int
check_header (struct input_ty *deeper)
{
  unsigned len;
  for (len = 0; len < 6; len++)
    if (((deeper)->buffer_position < (deeper)->buffer_end
         ? *((deeper)->buffer_position)++
         : input_getc_complicated((deeper))) < 0)
      return 0;
  return 1;
}

struct input_ty s;
unsigned char b[6];

int
main (void)
{
  s.buffer_position = b;
  s.buffer_end = b + sizeof b;
  if (!check_header(&s))
    return 1;
  if (s.buffer_position != s.buffer_end)
    abort();
  return 0;
}


it looks like ifcvt messes up in pass 3 and puts the post-inc in the cond-exec
block.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|middle-end                  |rtl-optimization
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-08-08 09:09:48
               date|                            |


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


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

* [Bug rtl-optimization/28636] [4.0/4.1 regression] Miscompiled loop
  2006-08-07 16:34 [Bug middle-end/28636] New: [4.0/4.1 regression] Miscompiled loop schwab at suse dot de
                   ` (4 preceding siblings ...)
  2006-08-08  9:09 ` [Bug rtl-optimization/28636] " rguenth at gcc dot gnu dot org
@ 2006-09-09 22:10 ` ebotcazou at gcc dot gnu dot org
  2006-09-10 21:27 ` ebotcazou at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2006-09-09 22:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from ebotcazou at gcc dot gnu dot org  2006-09-09 22:09 -------
> it looks like ifcvt messes up in pass 3 and puts the post-inc in the
> cond-exec block.

It's actually the combiner that wrongly ditches the post-inc, at least with
the last set of options you posted.  Amazingly enough, on the 4.1 branch, the
combiner is the first pass which deduces that

  *((deeper)->buffer_position)++ < 0

is always false.  In particular, we have this little gem in t97.final_cleanup

  unsigned char * D.1386;
  _Bool iftmp.0;

  iftmp.0 = (int) *D.1386 < 0;

even at -O2!  This is optimized on mainline, which hides the problem there.

Fixing...


-- 

ebotcazou at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |ebotcazou at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2006-08-08 09:09:48         |2006-09-09 22:09:59
               date|                            |


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


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

* [Bug rtl-optimization/28636] [4.0/4.1 regression] Miscompiled loop
  2006-08-07 16:34 [Bug middle-end/28636] New: [4.0/4.1 regression] Miscompiled loop schwab at suse dot de
                   ` (5 preceding siblings ...)
  2006-09-09 22:10 ` ebotcazou at gcc dot gnu dot org
@ 2006-09-10 21:27 ` ebotcazou at gcc dot gnu dot org
  2006-09-10 21:28 ` ebotcazou at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2006-09-10 21:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from ebotcazou at gcc dot gnu dot org  2006-09-10 21:27 -------
Subject: Bug 28636

Author: ebotcazou
Date: Sun Sep 10 21:27:36 2006
New Revision: 116827

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116827
Log:
        PR rtl-optimization/28636
        * combine.c (force_to_mode): Test for side-effects before
        substituting by zero.
        (simplify_shift_const): Likewise for zero or other constants.


Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/20060910-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/combine.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug rtl-optimization/28636] [4.0/4.1 regression] Miscompiled loop
  2006-08-07 16:34 [Bug middle-end/28636] New: [4.0/4.1 regression] Miscompiled loop schwab at suse dot de
                   ` (6 preceding siblings ...)
  2006-09-10 21:27 ` ebotcazou at gcc dot gnu dot org
@ 2006-09-10 21:28 ` ebotcazou at gcc dot gnu dot org
  2006-09-10 21:29 ` ebotcazou at gcc dot gnu dot org
  2006-09-10 21:34 ` ebotcazou at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2006-09-10 21:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from ebotcazou at gcc dot gnu dot org  2006-09-10 21:28 -------
Subject: Bug 28636

Author: ebotcazou
Date: Sun Sep 10 21:28:03 2006
New Revision: 116828

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116828
Log:
        PR rtl-optimization/28636
        * combine.c (force_to_mode): Test for side-effects before
        substituting by zero.
        (simplify_shift_const): Likewise for zero or other constants.


Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.c-torture/execute/20060910-1.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/combine.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug rtl-optimization/28636] [4.0/4.1 regression] Miscompiled loop
  2006-08-07 16:34 [Bug middle-end/28636] New: [4.0/4.1 regression] Miscompiled loop schwab at suse dot de
                   ` (7 preceding siblings ...)
  2006-09-10 21:28 ` ebotcazou at gcc dot gnu dot org
@ 2006-09-10 21:29 ` ebotcazou at gcc dot gnu dot org
  2006-09-10 21:34 ` ebotcazou at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2006-09-10 21:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from ebotcazou at gcc dot gnu dot org  2006-09-10 21:28 -------
Subject: Bug 28636

Author: ebotcazou
Date: Sun Sep 10 21:28:39 2006
New Revision: 116829

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116829
Log:
        PR rtl-optimization/28636
        * combine.c (force_to_mode): Test for side-effects before
        substituting by zero.
        (simplify_shift_const): Likewise for zero or other constants.


Added:
    branches/gcc-4_0-branch/gcc/testsuite/gcc.c-torture/execute/20060910-1.c
Modified:
    branches/gcc-4_0-branch/gcc/ChangeLog
    branches/gcc-4_0-branch/gcc/combine.c
    branches/gcc-4_0-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug rtl-optimization/28636] [4.0/4.1 regression] Miscompiled loop
  2006-08-07 16:34 [Bug middle-end/28636] New: [4.0/4.1 regression] Miscompiled loop schwab at suse dot de
                   ` (8 preceding siblings ...)
  2006-09-10 21:29 ` ebotcazou at gcc dot gnu dot org
@ 2006-09-10 21:34 ` ebotcazou at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2006-09-10 21:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from ebotcazou at gcc dot gnu dot org  2006-09-10 21:34 -------
Fixed everywhere.


-- 

ebotcazou at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2006-
                   |                            |09/msg00383.html
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2006-09-10 21:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-07 16:34 [Bug middle-end/28636] New: [4.0/4.1 regression] Miscompiled loop schwab at suse dot de
2006-08-07 16:34 ` [Bug middle-end/28636] " schwab at suse dot de
2006-08-07 17:34 ` pinskia at gcc dot gnu dot org
2006-08-07 17:51 ` schwab at suse dot de
2006-08-08  0:04 ` schwab at suse dot de
2006-08-08  9:09 ` [Bug rtl-optimization/28636] " rguenth at gcc dot gnu dot org
2006-09-09 22:10 ` ebotcazou at gcc dot gnu dot org
2006-09-10 21:27 ` ebotcazou at gcc dot gnu dot org
2006-09-10 21:28 ` ebotcazou at gcc dot gnu dot org
2006-09-10 21:29 ` ebotcazou at gcc dot gnu dot org
2006-09-10 21:34 ` ebotcazou 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).