public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/10087: [3.3/3.4 regression] optimizer produces wrong code when indexing 2D array
@ 2003-03-24 18:58 mmitchel
  0 siblings, 0 replies; 5+ messages in thread
From: mmitchel @ 2003-03-24 18:58 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, p.van-hoof

Synopsis: [3.3/3.4 regression] optimizer produces wrong code when indexing 2D array

State-Changed-From-To: analyzed->closed
State-Changed-By: mmitchel
State-Changed-When: Mon Mar 24 18:56:00 2003
State-Changed-Why:
    Fixed in GCC 3.3, GCC 3.4.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10087


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

* Re: optimization/10087: [3.3/3.4 regression] optimizer produces wrong code when indexing 2D array
@ 2003-03-21 19:46 Glen Nakamura
  0 siblings, 0 replies; 5+ messages in thread
From: Glen Nakamura @ 2003-03-21 19:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR optimization/10087; it has been noted by GNATS.

From: Glen Nakamura <glen@imodulo.com>
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, p.van-hoof@qub.ac.uk
Cc:  
Subject: Re: optimization/10087: [3.3/3.4 regression] optimizer produces wrong code when indexing 2D array
Date: Fri, 21 Mar 2003 09:37:36 -1000

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10087
 
 Additional analysis of the problem and patch located at:
 http://gcc.gnu.org/ml/gcc-patches/2003-03/msg01932.html
 
 The proposed fix is somewhat hackish, but it should fix the problem.
 BTW, I didn't update the comments about the use of 'same' in struct induction
 for bivs in loop.h
 
 - glen


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

* Re: optimization/10087: [3.3/3.4 regression] optimizer produces wrong code when indexing 2D array
@ 2003-03-15  0:56 Steven Bosscher
  0 siblings, 0 replies; 5+ messages in thread
From: Steven Bosscher @ 2003-03-15  0:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR optimization/10087; it has been noted by GNATS.

From: Steven Bosscher <s.bosscher@student.tudelft.nl>
To: p.van-hoof@qub.ac.uk, gcc-gnats@gcc.gnu.org,
	gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org
Cc:  
Subject: Re: optimization/10087: [3.3/3.4 regression] optimizer produces wrong
 code when indexing 2D array
Date: Sat, 15 Mar 2003 01:48:02 +0100

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10087
 
 A little more information...
 
 A slightly smaller test case is:
 ----------------------------
 static void
 b (int *i, int *j)
 {
 }
 
 int
 main (void)
 {
   int i, j;
 
   S x1[2][2];
   S *x[2] = { x1[0], x1[1] };
   S **E = x;
 
   for (i = 0; i < 2; i++)
     for (j = 0; j < 2; j++)
       E[j][i].T1 = 1;
 
   b (&j, &i);
   printf ("result %.6e\n", E[1][1].T1);
   return 0;
 }
 ----------------------------
 
 The line "E[j][i] =..." seems to be the problem:
 With j first, then i, the output is wrong (and you get a segfault as a 
 bonus).
 With i first, then j ("E[i][j]=..")  you get the  correct result.
 
 # gcc-3.3 -O t.c
 # a.out
 result 1.000000e+00
 # gcc-3.3 t.c -O -fstrength-reduce -fstrict-aliasing -fforce-mem -fgcse
 # a.out
 result 2.676500e+00
 Segmentation fault
 
 Again, disable any of these four options and you get the expected output.
 
 (For the record, this is on i586-pc-linux-gnu.)
 
 Greetz
 Steven
 
 


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

* Re: optimization/10087: [3.3/3.4 regression] optimizer produces wrong code when indexing 2D array
@ 2003-03-15  0:06 Steven Bosscher
  0 siblings, 0 replies; 5+ messages in thread
From: Steven Bosscher @ 2003-03-15  0:06 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR optimization/10087; it has been noted by GNATS.

From: Steven Bosscher <s.bosscher@student.tudelft.nl>
To: p.van-hoof@qub.ac.uk, gcc-gnats@gcc.gnu.org,
	gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org
Cc:  
Subject: Re: optimization/10087: [3.3/3.4 regression] optimizer produces wrong
 code when indexing 2D array
Date: Sat, 15 Mar 2003 01:01:01 +0100

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10087
 
 # gcc-3.3 10087.c -O
 # a.out
 result 1.000000e+00
 # gcc-3.3 10087.c -O -fforce-mem -fstrength-reduce -fgcse
 # a.out
 result -1.997810e+00
 
 Turning off any of these three options makes the output equal to 
 unoptimized or -O.
 
 Greetz
 Steven
 
 


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

* Re: optimization/10087: [3.3/3.4 regression] optimizer produces wrong code when indexing 2D array
@ 2003-03-14 23:45 bangerth
  0 siblings, 0 replies; 5+ messages in thread
From: bangerth @ 2003-03-14 23:45 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, p.van-hoof

Old Synopsis: optimizer produces wrong code when indexing malloc'ed 2D array
New Synopsis: [3.3/3.4 regression] optimizer produces wrong code when indexing 2D array

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Fri Mar 14 23:45:17 2003
State-Changed-Why:
    Confirmed also on x86 linux. Here's a slightly modified example:
    --------------------------
    void b(int*,int*);
    
    typedef struct {
        double T1;
        char c;
    } S;
    
    int main(void)
    {
      int i,j;
      double s;
    
      S x1[2][2];
      S *x[2] = { x1[0], x1[1] };
      S **E = x;
      
      for( i=0; i < 2; i++ )
        for( j=0; j < 2; j++ )
          E[j][i].T1 = 1;
    
      for( i=0; i < 2; i++ )
        for( j=0; j < 2; j++ )
          s = E[j][i].T1;
    
      b(&j,&i);
      printf( "result %.6e\n", s);
      return 0;
    }
    
    void b(int *i, int *j) {}
    -------------------------------
    
    This yields different results with and without -O2:
    g/x> /home/bangerth/bin/gcc-3.4-pre/bin/gcc x.c
    g/x> ./a.out
    result 1.000000e+00
    
    g/x> /home/bangerth/bin/gcc-3.4-pre/bin/gcc x.c -O2
    g/x> ./a.out
    result 2.171654e+00
    
    The same holds for 3.3, but 3.2.2 is ok, so it's a regression.
    
    W.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10087


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

end of thread, other threads:[~2003-03-24 18:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-24 18:58 optimization/10087: [3.3/3.4 regression] optimizer produces wrong code when indexing 2D array mmitchel
  -- strict thread matches above, loose matches on Subject: below --
2003-03-21 19:46 Glen Nakamura
2003-03-15  0:56 Steven Bosscher
2003-03-15  0:06 Steven Bosscher
2003-03-14 23:45 bangerth

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