public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/23657] New: Wrong code generated: too much optimized out
@ 2005-08-31 16:05 qrczak at knm dot org dot pl
  2005-08-31 16:23 ` [Bug tree-optimization/23657] [4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: qrczak at knm dot org dot pl @ 2005-08-31 16:05 UTC (permalink / raw)
  To: gcc-bugs

/* The result should be 7. When compiled with
   gcc version 4.1.0 20050815 (experimental)
   with some patches from PLD (incl. PR7776, PR20297, PR23128, PR22533, PR23386)
   with -O, the result is 0. */
#include <stdio.h>
int arr[100];
int *alloc(void) {return arr;}
void fill(int n) {
   int *result = alloc();
   int *dest = result;
   for(;;) {
      int *next;
      dest[0] = 7;
      if (--n == 0) break;
      next = dest + 1;
      dest = next;
   }
}
int main(void) {
   fill(5);
   printf("%d\n", arr[1]);
   return 0;
}
/* Looking at the generated assembly code, the whole loop is optimized out,
   except for filling the first element. Using less temporaries or inlining
   alloc() makes the bug disappear. The bug manifests only with optimization 
   turned on. */

-- 
           Summary: Wrong code generated: too much optimized out
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: qrczak at knm dot org dot pl
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug tree-optimization/23657] [4.1 Regression] Wrong code generated: too much optimized out
  2005-08-31 16:05 [Bug c/23657] New: Wrong code generated: too much optimized out qrczak at knm dot org dot pl
@ 2005-08-31 16:23 ` pinskia at gcc dot gnu dot org
  2005-08-31 22:14 ` qrczak at knm dot org dot pl
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-31 16:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-31 16:19 -------
Confirmed, between t41.copyrename2 and t42.dom2, the V_MAY_DEF is removed.
After
  *next_8 = 7;

Before:
  #   TMT.51_18 = V_MAY_DEF <TMT.51_4>;
  *dest_2 = 7;

I think we are forgetting to copy the alias info.
I think this is fixed by the patch for PR 23509:
http://gcc.gnu.org/ml/gcc-patches/2005-08/msg01647.html

The tree-cfg.c part that is.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
          Component|c                           |tree-optimization
     Ever Confirmed|                            |1
  GCC build triplet|i686-pc-linux-gnu           |
   GCC host triplet|i686-pc-linux-gnu           |
 GCC target triplet|i686-pc-linux-gnu           |
           Keywords|                            |alias, wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2005-08-31 16:19:38
               date|                            |
            Summary|Wrong code generated: too   |[4.1 Regression] Wrong code
                   |much optimized out          |generated: too much
                   |                            |optimized out
   Target Milestone|---                         |4.1.0


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


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

* [Bug tree-optimization/23657] [4.1 Regression] Wrong code generated: too much optimized out
  2005-08-31 16:05 [Bug c/23657] New: Wrong code generated: too much optimized out qrczak at knm dot org dot pl
  2005-08-31 16:23 ` [Bug tree-optimization/23657] [4.1 Regression] " pinskia at gcc dot gnu dot org
@ 2005-08-31 22:14 ` qrczak at knm dot org dot pl
  2005-08-31 22:23 ` qrczak at knm dot org dot pl
  2005-08-31 22:23 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: qrczak at knm dot org dot pl @ 2005-08-31 22:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From qrczak at knm dot org dot pl  2005-08-31 22:11 -------
> I think this is fixed by the patch for PR 23509:
> http://gcc.gnu.org/ml/gcc-patches/2005-08/msg01647.html

Indeed, applying this patch and recompiling gcc fixed the bug. Thanks.


-- 


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


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

* [Bug tree-optimization/23657] [4.1 Regression] Wrong code generated: too much optimized out
  2005-08-31 16:05 [Bug c/23657] New: Wrong code generated: too much optimized out qrczak at knm dot org dot pl
  2005-08-31 16:23 ` [Bug tree-optimization/23657] [4.1 Regression] " pinskia at gcc dot gnu dot org
  2005-08-31 22:14 ` qrczak at knm dot org dot pl
@ 2005-08-31 22:23 ` qrczak at knm dot org dot pl
  2005-08-31 22:23 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: qrczak at knm dot org dot pl @ 2005-08-31 22:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From qrczak at knm dot org dot pl  2005-08-31 22:23 -------


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

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


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


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

* [Bug tree-optimization/23657] [4.1 Regression] Wrong code generated: too much optimized out
  2005-08-31 16:05 [Bug c/23657] New: Wrong code generated: too much optimized out qrczak at knm dot org dot pl
                   ` (2 preceding siblings ...)
  2005-08-31 22:23 ` qrczak at knm dot org dot pl
@ 2005-08-31 22:23 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-31 22:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-08-31 22:14 -------
(In reply to comment #2)
> Indeed, applying this patch and recompiling gcc fixed the bug. Thanks.

Thanks for trying the patch. I only thought about this patch because of the symptom was about the 
same as other bug was.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2005-
                   |                            |08/msg01647.html
           Keywords|                            |patch


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


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

end of thread, other threads:[~2005-08-31 22:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-31 16:05 [Bug c/23657] New: Wrong code generated: too much optimized out qrczak at knm dot org dot pl
2005-08-31 16:23 ` [Bug tree-optimization/23657] [4.1 Regression] " pinskia at gcc dot gnu dot org
2005-08-31 22:14 ` qrczak at knm dot org dot pl
2005-08-31 22:23 ` qrczak at knm dot org dot pl
2005-08-31 22:23 ` pinskia 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).