home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.sun.misc
- Path: sparky!uunet!psinntp!ims.com!kestrel!davek
- From: davek@kestrel.ims.com (Dave Koon)
- Subject: Re: sun cc optimization failure
- Message-ID: <1992Sep10.163247.22854@ims.com>
- Sender: usenet@ims.com (USENET News Poster)
- Reply-To: davek@kestrel.ims.com
- Organization: Integrated Measurement Systems
- References: <etxkrjg.716039624@solsta-c>
- Date: Thu, 10 Sep 1992 16:32:47 GMT
- Lines: 84
-
- Without sounding defensive, I wonder what the difference between what I did
- and what Kristian did.
- *****************************************************************************
- zaphod:/css/davek> more test.c
- main() {
- int i,j,ax;
- ax = 0;
- for(i=0;i<3;i++){
- j = ax * i;
- puts("in for loop");
- }
- }
-
- zaphod:/css/davek> more /etc/motd
- SunOS Release 4.1.2 (GENERIC) #2: Wed Oct 23 10:52:58 PDT 1991
- zaphod:/css/davek> cc test.c -o test
- zaphod:/css/davek> ./test
- in for loop
- in for loop
- in for loop
- zaphod:/css/davek> cc -O test.c -o test
- zaphod:/css/davek> ./test
- in for loop
- in for loop
- in for loop
- zaphod:/css/davek> cc -O1 test.c -o test
- zaphod:/css/davek> ./test
- in for loop
- in for loop
- in for loop
- zaphod:/css/davek> cc -O2 test.c -o test
- zaphod:/css/davek> ./test
- in for loop
- in for loop
- in for loop
- zaphod:/css/davek> cc -O3 test.c -o test
- zaphod:/css/davek> ./test
- in for loop
- in for loop
- in for loop
- zaphod:/css/davek> cc -O4 test.c -o test
- zaphod:/css/davek> ./test
- in for loop
- in for loop
- in for loop
- *******************************************************************************
-
- In article 716039624@solsta-c, etxkrjg@solsta.ericsson.se (Kristian Jorg TX/DKL) writes:
- >davek@kestrel.ims.com (Dave Koon) writes:
- >
- >>In article 16902@mr.med.ge.com, carl@aslmr-serv.med.ge.com (Carl Crawford) writes:
- >>>
- >>>consider the following program:
- >>>
- >>>main() {
- >>> int i,j,ax;
- >>> ax = 0;
- >>> for(i=0;i<3;i++){
- >>> j = ax * i;
- >>> puts("in for loop");
- >>> }
- >>>}
- >>>when compiled with cc (sun os 4.1 on sparc 1+), the
- >>>code runs thru the loop three times. when comiled with
- >>>the -O flag it only runs once. hom come the optimization
- >>>screws up the loop?
- >
- >>Try upgrading your machine to either 4.1.1 or 4.1.2. I ran
- >>your test program and did not see the problem with either 4.1.1
- >>or 4.1.2.
- >
- >No, the problem still exists in 4.1.2. I experienced exactly the same
- >behaviour as described above.
- >
- >
- >
- >--
- >----------------------------------------------------------------------------
- >Kristian Jorg, Software Design Support and Methods ! I speak for myself and
- >Ericsson Telecom AB, Karlstad, Sweden ! Not for my company!
- >E-mail: etxkrjg@solsta.ericsson.se !
-
-
-
-