public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc 3.3 / i386 / -O2 question
@ 2004-11-16 12:06 Beschorner Daniel
  2004-11-16 12:15 ` Luca Benini
  2004-11-16 13:02 ` Andrew Haley
  0 siblings, 2 replies; 22+ messages in thread
From: Beschorner Daniel @ 2004-11-16 12:06 UTC (permalink / raw)
  To: 'gcc@gcc.gnu.org'

Sorry, if this is the wrong list, but why differ the results in this simple
example when compiled with -O and -O2 while GCC 2.95 is working fine?
-fno-strict-aliasing makes no difference, but -fno-gcse-(sm) helps.

outputs are
-O: -1343238496
-O2: -1474736480

Thanks Daniel


int A,B,C;
int i;
int Q[1];
int H(int X, int Y)
{
        return X*Y;
}
int main()
{
        A=B=C=100000;
        A+=H(B,C);
        C+=H(A,B);
        A+=H(B,C);
        C+=H(A,B);
        for (i=0;i<1;i++)
                Q[i] = 0;
        printf("%i\n",A);
        return 0;
}

^ permalink raw reply	[flat|nested] 22+ messages in thread
* RE: gcc 3.3 / i386 / -O2 question
@ 2004-11-16 13:46 Beschorner Daniel
  0 siblings, 0 replies; 22+ messages in thread
From: Beschorner Daniel @ 2004-11-16 13:46 UTC (permalink / raw)
  To: 'Andrew Haley'; +Cc: 'gcc@gcc.gnu.org'

Thank you!
The unused array Q seems to trigger somewhat, if I remove it O2 works fine.
Strange... 

Daniel

-----Ursprüngliche Nachricht-----
Von: Andrew Haley [mailto:aph@redhat.com] 
Gesendet: Dienstag, 16. November 2004 13:14
An: Beschorner Daniel
Cc: 'gcc@gcc.gnu.org'
Betreff: gcc 3.3 / i386 / -O2 question

Beschorner Daniel writes:
 > Sorry, if this is the wrong list, but why differ the results in this
simple  > example when compiled with -O and -O2 while GCC 2.95 is working
fine?
 > -fno-strict-aliasing makes no difference, but -fno-gcse-(sm) helps.
 >
 > outputs are
 > -O: -1343238496
 > -O2: -1474736480
 >
 > Thanks Daniel
 >
 >
 > int A,B,C;
 > int i;
 > int Q[1];
 > int H(int X, int Y)
 > {
 >         return X*Y;
 > }
 > int main()
 > {
 >         A=B=C=100000;
 >         A+=H(B,C);

Integer overflow.  All bets are off.

Andrew.

^ permalink raw reply	[flat|nested] 22+ messages in thread
* RE: gcc 3.3 / i386 / -O2 question
@ 2004-11-16 16:05 Beschorner Daniel
  2004-11-17  1:23 ` Gerald Pfeifer
  0 siblings, 1 reply; 22+ messages in thread
From: Beschorner Daniel @ 2004-11-16 16:05 UTC (permalink / raw)
  To: gcc; +Cc: 'gcc-help@gcc.gnu.org'

Thanks a lot for your effort to all who tested this code with me!
There is some evidence for a SuSE linux specific problem in my GCC 3.3.3,
cause all others could compile it fine even with -O2.

Daniel

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

end of thread, other threads:[~2004-11-17 13:53 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-16 12:06 gcc 3.3 / i386 / -O2 question Beschorner Daniel
2004-11-16 12:15 ` Luca Benini
2004-11-16 13:02 ` Andrew Haley
2004-11-16 17:35   ` Luca Benini
2004-11-16 13:46 Beschorner Daniel
2004-11-16 16:05 Beschorner Daniel
2004-11-17  1:23 ` Gerald Pfeifer
2004-11-17 11:12   ` Dave Korn
2004-11-17 11:33     ` Luca Benini
2004-11-17 11:41       ` Robert Dewar
2004-11-17 11:59         ` Luca Benini
2004-11-17 12:15           ` Dave Korn
2004-11-17 12:17             ` Dave Korn
2004-11-17 13:06               ` Robert Dewar
2004-11-17 13:52             ` Luca Benini
2004-11-17 12:46           ` Robert Dewar
2004-11-17 12:45       ` Steven Bosscher
2004-11-17 12:56         ` Joseph S. Myers
2004-11-17 13:19           ` Robert Dewar
2004-11-17 13:08         ` Robert Dewar
2004-11-17 13:40     ` Michael Matz
2004-11-17 13:55       ` Robert Dewar

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