public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: -O2 problem / GCC 3.3.x
@ 2004-11-15 22:07 Bossom, John
  0 siblings, 0 replies; 4+ messages in thread
From: Bossom, John @ 2004-11-15 22:07 UTC (permalink / raw)
  To: Beschorner Daniel, gcc-help

I would not have expected this to fail with -fgcse
According to the documentation it performa a global common subexpression elimination pass as well
as global constant and copy propagation.

Then again, you are going to get rounding errors (I believe the results overflow, hence, one could
argue that the results you are getting to begin with are suspect - I guess it would be nice if
they failed the same way)

-----Original Message-----
From: Beschorner Daniel [mailto:Daniel.Beschorner@facton.com]
Sent: Monday, November 15, 2004 4:51 PM
To: Bossom, John; gcc-help@gcc.gnu.org
Subject: RE: -O2 problem / GCC 3.3.x


Thank you!

I tested on your advice (i386 hardware)...

-O2 -fno-strict-aliasing, still wrong result
but
-O2 -fno-gcse, correct result

Daniel

-----Ursprüngliche Nachricht-----
Von: Bossom, John [mailto:John.Bossom@Cognos.COM]
Gesendet: Montag, 15. November 2004 21:53
An: Beschorner Daniel; gcc-help@gcc.gnu.org
Betreff: RE: -O2 problem / GCC 3.3.x


Read up on -fstrict-aliasing (which is on with -O2).

Try building again with -O2 -fno-strict-aliasing

(Not saying this is the problem, however, if it goes away with the
-fno-strict-aliasing
 then you'll know)


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
Behalf Of Beschorner Daniel
Sent: Monday, November 15, 2004 3:42 PM
To: 'gcc-help@gcc.gnu.org'
Subject: -O2 problem / GCC 3.3.x


Any idea why results differ between -O and -O2 with GCC 3.3.x/Linux??? GCC
2.95 works fine.

results:
-O	500000
-O2	300000

Thanks
Daniel



#include <stdio.h>

int A,B,C;
int i;
int Q[1];

int H(int X, int Y)
{
        return X^Y^100000;
}

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;
} 
  
       This message may contain privileged and/or confidential information.
If you have received this e-mail in error or are not the intended recipient,
you may not use, copy, disseminate or distribute it; do not open any
attachments, delete it immediately from your system and notify the sender
promptly by e-mail that you have done so.  Thank you. 
 

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

* RE: -O2 problem / GCC 3.3.x
@ 2004-11-15 21:51 Beschorner Daniel
  0 siblings, 0 replies; 4+ messages in thread
From: Beschorner Daniel @ 2004-11-15 21:51 UTC (permalink / raw)
  To: 'Bossom, John', gcc-help

Thank you!

I tested on your advice (i386 hardware)...

-O2 -fno-strict-aliasing, still wrong result
but
-O2 -fno-gcse, correct result

Daniel

-----Ursprüngliche Nachricht-----
Von: Bossom, John [mailto:John.Bossom@Cognos.COM]
Gesendet: Montag, 15. November 2004 21:53
An: Beschorner Daniel; gcc-help@gcc.gnu.org
Betreff: RE: -O2 problem / GCC 3.3.x


Read up on -fstrict-aliasing (which is on with -O2).

Try building again with -O2 -fno-strict-aliasing

(Not saying this is the problem, however, if it goes away with the
-fno-strict-aliasing
 then you'll know)


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
Behalf Of Beschorner Daniel
Sent: Monday, November 15, 2004 3:42 PM
To: 'gcc-help@gcc.gnu.org'
Subject: -O2 problem / GCC 3.3.x


Any idea why results differ between -O and -O2 with GCC 3.3.x/Linux??? GCC
2.95 works fine.

results:
-O	500000
-O2	300000

Thanks
Daniel



#include <stdio.h>

int A,B,C;
int i;
int Q[1];

int H(int X, int Y)
{
        return X^Y^100000;
}

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;
} 
  
       This message may contain privileged and/or confidential information.
If you have received this e-mail in error or are not the intended recipient,
you may not use, copy, disseminate or distribute it; do not open any
attachments, delete it immediately from your system and notify the sender
promptly by e-mail that you have done so.  Thank you. 
 

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

* RE: -O2 problem / GCC 3.3.x
@ 2004-11-15 20:53 Bossom, John
  0 siblings, 0 replies; 4+ messages in thread
From: Bossom, John @ 2004-11-15 20:53 UTC (permalink / raw)
  To: Beschorner Daniel, gcc-help

Read up on -fstrict-aliasing (which is on with -O2).

Try building again with -O2 -fno-strict-aliasing

(Not saying this is the problem, however, if it goes away with the -fno-strict-aliasing
 then you'll know)


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On
Behalf Of Beschorner Daniel
Sent: Monday, November 15, 2004 3:42 PM
To: 'gcc-help@gcc.gnu.org'
Subject: -O2 problem / GCC 3.3.x


Any idea why results differ between -O and -O2 with GCC 3.3.x/Linux??? GCC
2.95 works fine.

results:
-O	500000
-O2	300000

Thanks
Daniel



#include <stdio.h>

int A,B,C;
int i;
int Q[1];

int H(int X, int Y)
{
        return X^Y^100000;
}

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;
} 
  
       This message may contain privileged and/or confidential information.  If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so.  Thank you. 
 

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

* -O2 problem / GCC 3.3.x
@ 2004-11-15 20:42 Beschorner Daniel
  0 siblings, 0 replies; 4+ messages in thread
From: Beschorner Daniel @ 2004-11-15 20:42 UTC (permalink / raw)
  To: 'gcc-help@gcc.gnu.org'

Any idea why results differ between -O and -O2 with GCC 3.3.x/Linux??? GCC
2.95 works fine.

results:
-O	500000
-O2	300000

Thanks
Daniel



#include <stdio.h>

int A,B,C;
int i;
int Q[1];

int H(int X, int Y)
{
        return X^Y^100000;
}

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] 4+ messages in thread

end of thread, other threads:[~2004-11-15 22:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-15 22:07 -O2 problem / GCC 3.3.x Bossom, John
  -- strict thread matches above, loose matches on Subject: below --
2004-11-15 21:51 Beschorner Daniel
2004-11-15 20:53 Bossom, John
2004-11-15 20:42 Beschorner Daniel

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