qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 01/15] audio: replace open-coded buffer arithmetic


From: Gerd Hoffmann
Subject: Re: [PATCH v2 01/15] audio: replace open-coded buffer arithmetic
Date: Wed, 26 Jan 2022 09:48:25 +0100

  Hi,

> > > --- a/audio/audio_int.h
> > > +++ b/audio/audio_int.h
> > > @@ -266,6 +266,12 @@ static inline size_t audio_ring_dist(size_t dst, 
> > > size_t src, size_t len)
> > >       return (dst >= src) ? (dst - src) : (len - src + dst);
> > >   }
> > You haven't touched this function, but while I am looking at it, all 
> > function
> > arguments are unsigned. So probably modulo operator might be used to get rid
> > of a branch here.
> 
> That would be "return (len - dist + pos) % len;" but on my x86_64 system I
> always prefer a conditional move instruction to a 64 bit integer division
> instruction.

Why?  Performance?

Don't underestimate the optimizer of a modern compiler.  In many cases
it simply isn't worth the effort.  Better optimize the code for humans,
i.e. make it easy to read and understand.

take care,
  Gerd




reply via email to

[Prev in Thread] Current Thread [Next in Thread]