[cairo] Optimize spans in the trapezoid rasterizer

Keith Packard keithp at keithp.com
Mon Jul 25 16:01:42 PDT 2005


On Tue, 2005-07-26 at 14:48 +1200, Robert O'Callahan wrote:

> It depends on whether the branch is predictable or not. Unpredictable
> branches will kill performance, predictable branches are almost free.
> "Predictable" basically means "the next value for the condition is
> usually the same as the previous one".
> 
> For this particular piece of code, a good compiler/architecture will
> actually use predicated execution/conditional moves to eliminate the
> conditional branch, so that predictability no longer matters. In fact,
> gcc -O2 turns your saturation statement into a CMOV on -mi686 or
> greater.

I guess the question is how this compares to the branch-less equivalent
code on our target architectures.  I consider these to be AMD64, x86 and
ARM, although I'm sure others would include additional ones.

I cannot get GCC 4.0.1 to generate the CMOV instruction; -march=i686 -O2
generates a branch. Presumably, I'm just driving the compiler
incorrectly. The non-branching code generates:

(16-bit  value in %eax)

        movl    %eax, %edx
        shrl    $8, %edx
        negb    %dl
        orb     %al, %dl

(8-bit value in %al)

-keith

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050725/7dfea138/attachment.pgp


More information about the cairo mailing list