Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!umich!yale!cmcl2!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.lang.misc Subject: Re: Compiler Costs Message-ID: <56704@lanl.gov> Date: 11 Jul 90 20:34:02 GMT References: <1319@fs1.ee.ubc.ca> Organization: Los Alamos Natl Lab, Los Alamos, N.M. Lines: 19 From article <1319@fs1.ee.ubc.ca>, by mikeb@salmon.ee.ubc.ca (Mike Bolotski): > In article <2681@awdprime.UUCP>, tif@doorstop.austin.ibm.com (Paul > Chamberlain) writes: >> P.S. Another good example is parity. Takes about 25 instructions >> in C, about 1 in assembly (using intel anyway). > Deja voodoo. Lookup table. 3-4 instructions. Maybe less, depending on > addressing modes available. Works just fine (but still slower than the assemble - by a lot) - provided that you are doing parity checking of something _small_, like a single byte. The table gets kind of large for a 32-bit integer. Similarly, population counts and leading (trailing) zero (one) counts are not the kind of thing that you'd want to do with table look-ups. Of course, no HLL I know of lets you inline assembly - the best solution. _SOME_ implementations of C, Pascal, Fortran, even BASIC allow such inlining, but the capability is not standard (makes your code - shudder - machine dependent). J. Giles