[Pixman] Use of bitwise operators on vectors with Boolean results

Siarhei Siamashka siarhei.siamashka at gmail.com
Thu Jun 26 09:07:35 PDT 2014


On Sun, 22 Jun 2014 12:43:49 +0200
Michael Tautschnig <mt at debian.org> wrote:

> Dear Pixman Developers,
> 
> While doing some experiments using a toolkit built around CBMC we noticed that
> test/utils-prng.c has code like
> 
>   randdata.vb |= (t.vb >= const_C0);
> 
> (http://cgit.freedesktop.org/pixman/tree/test/utils-prng.c#n131)
> 
> with all operands being vectors. While our type checker struggled here, there
> isn't necessarily anything wrong with this statement. Yet I was wondering
> whether this was really doing what the developer intended to do: effectively
> this will either leave randdata.vb unchanged (if the right-hand side is false)
> or will set all (!) bits of randdata.vb

Instead of using just uniformly distributed random data in the images
for pixman tests, we are interested in random data with the higher
probability for 0xFF and 0x00 bytes (because there are many special
code paths for fully opaque and fully transparent cases in the pixman
code).

This particular line of code takes the uniformly distributed pseudo
random data and is changing each byte in it to 0xFF with 1/4
probability.

> as, at least on the platforms that I tried, comparisons on vectors yield
> (unsigned)-1 as representation of "true."

Yes, this behaves exactly as documented at:

    https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html

"Vectors are compared element-wise producing 0 when comparison is false
and -1 (constant of the appropriate type where all bits are set)
otherwise."

-- 
Best regards,
Siarhei Siamashka


More information about the Pixman mailing list