[gst-devel] [gst-cvs] gstreamer: micro-optim: if (x) is cheaper than if (x > 0) for unsigned integers

David Schleef ds at entropywave.com
Fri Dec 3 20:17:06 CET 2010


On Fri, Dec 03, 2010 at 12:59:33PM +0100, Edward Hervey wrote:
> On Fri, 2010-12-03 at 11:47 +0000, Tim-Philipp Müller wrote:
> > On Fri, 2010-12-03 at 03:04 -0800, Edward Hervey wrote:
> > 
> > > Module: gstreamer
> > > Branch: master
> > > Commit: 6aa8ca37eeb9debfa6919741a023250bf278248f
> > > URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=6aa8ca37eeb9debfa6919741a023250bf278248f
> > > 
> > > Author: Edward Hervey <bilboed at bilboed.com>
> > > Date:   Sat Apr 11 15:04:41 2009 +0200
> > > 
> > > micro-optim: if (x) is cheaper than if (x > 0) for unsigned integers
> > 
> > I really really dislike this change. Is it really worth it?
> 
>   I saw gcc asm where it was doing an expensive compare as opposed to a
> fast != 0. So yes, needed. Worth it ? Well I did title it "micro-optim".

What is an expensive compare?  cmp $0, %eax and test %eax, %eax are
both one cycle.  It is somewhat amusing that gcc-4.5 generates
different code for these, when it should know they are identical.
gcc-4.4 doesn't, so I consider that a regression, but certainly not
an important one.

> Date:   Sat Apr 11 15:04:41 2009 +0200

Hiding patches in our local tree, eh?



David





More information about the gstreamer-devel mailing list