On Wed, Dec 20, 2000 at 11:03:48AM +1030, Greg Lehey wrote:
> On Tuesday, 19 December 2000 at 16:01:52 -0800, David O'Brien wrote:
> > On Mon, Dec 18, 2000 at 01:11:12PM -0600, Jacques A. Vidrine wrote:
> >> /* Case 1 */ /* Case 2 */
> >> if (data) vs. free(data)
> >> free(data);
> >
> >
> > Actually from an optimization standpoint, #1 can be worse (ie, harder on
> > the processor). You've got a conditional jump there that is using branch
> > prediction HW to track (which means there is some other conditional
> > branch you're not, you're fetching both the taken and not take paths,
> > etc... If the function call isn't expensive, #2 can be "faster".
>
> In which processors is a function call anywhere near as cheap as a
> conditional local branch?
It is a known branch, thus no branch prediction resources and pre-fetch
of taken and not-take paths has to be done. I am not saying it is
definately cheaper but I do raise the point to remind people that there
is more to think about with today's processors than the simple CPU's most
studied in college.
--
-- David ([EMAIL PROTECTED])
GNU is Not Unix / Linux Is Not UniX
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message