www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/29/22:55:13

From: an096 AT yfn DOT ysu DOT edu (David A. Scott)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: bad code optimizations
Date: 30 Sep 1998 02:51:44 GMT
Organization: St. Elizabeth Hospital, Youngstown, OH
Lines: 67
Message-ID: <6us6c0$4i2$1@news.ysu.edu>
References: <6us48p$t1u$1 AT nnrp1 DOT dejanews DOT com>
Reply-To: an096 AT yfn DOT ysu DOT edu (David A. Scott)
NNTP-Posting-Host: yfn2.ysu.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In a previous article, tomstdenis AT my-dejanews DOT com () says:

>Sometimes I see things like:
>
>movl %eax,%eax

  This might be done to set flags. Also no
C compiler can come close to what any average program
can do if he takes his time. Since the programer is really
using addtional information that the complier can never
really know. And that is true of any high level language.

>
>in the outputed code?  That's really bad.
>
>Also, the following code:
>
>int test()
>{
>    return test2() % 4;
>}
>
>makes:
>
>_test:
>	pushl %ebp
>	movl %esp,%ebp
>	call _test2
>	movl %eax,%edx
>	testl %edx,%edx
>	jge L2
>	leal 15(%edx),%eax
>L2:
>	andb $240,%al
>	subl %eax,%edx
>	movl %edx,%eax
>	leave
>	ret
>
>
>The % 16, could be simplified into one bitshift, ala
>
>_test:
>	pushl %ebp
>	movl %esp,%ebp
>	call _test2
>        shll $4,%eax

  most compilers never really take advantage of the
full instruction set. I have noticed on old Univac
systems when fortran V was hot the old time complier
writers really made good use of the instruction sets.
But as time marched on the compliers became worse and 
worse at using the full set of instructions. I think it
is beacuse machines are so much faster and have so much
more memory that little attension goes to optimizing.
Also most high level compliers now a days are written
fast and for many machine types so attension to one
machine is hard to justify spending much time on.
 This is just my point of view I am sure others see
it from a different point of view.

-- 
http://cryptography.org/cgi-bin/crypto.cgi/Misc/scott19u.zip
for the version with a real key of voer one million bytes.
 also scott16u.zip and scott4u.zip

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019