[Mesa-dev] 16-bit comparisons in NIR
Giuseppe Bilotta
giuseppe.bilotta at gmail.com
Sat Apr 21 06:43:49 UTC 2018
On Sat, Apr 21, 2018 at 2:16 AM, Jason Ekstrand <jason at jlekstrand.net> wrote:
>
> I was thinking about this a bit this morning and it gets even more sticky.
> What happens if you have
>
> bool e = (a < b) && (c < d);
>
> where a and b are 16-bit and c and d are 32-bit? In this case, one
> comprison has a 32-bit value and one has a 16-bit value and you have to pick
> one for the &&.
In OpenCL C, relational operators don't return a bool, but a signed
integer type with the same size and number of components as the
operands; so, comparing scalar 16-bit data to scalar 16-bit data
(doesn't matter if short, ushort or half) would produce a short, and
comparing scalar 64-bit data to scalar 64-bit data would produce a
long (which in OpenCL C is always 64 bit); the same also holds for
vector types (so e.g. comparing a half8 to a half8 produces a short8).
So, in your example above, what would happen in OpenCL C would be this:
(a < b) would return a short (which is 16-bit in OpenCL C);
(c < d) would return an int (which is 32-bit in OpenCL C);
their logical combination would return a bool, with appropriate type promotion.
I don't suppose something like this could be implemented in NIR?
--
Giuseppe "Oblomov" Bilotta
More information about the mesa-dev
mailing list