[Mesa-dev] Mesa (master): glsl: Fix constant-folding for reciprocal expressions

Chad Versace chad at chad-versace.us
Wed Feb 2 16:52:30 PST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/02/2011 01:36 PM, Ian Romanick wrote:
> This behavior is actually correct.

That's unexpected...


> The 4.10 spec contains that language, but it also requires IEEE 754
> behavior.  Specifically, page 54 (page 59 of the PDF) says, "The
> following rules apply to both single and double-precision operations:
> Dividing by 0 results in the appropriately signed IEEE Inf."
> 
> For now I believe 1/0 for both integer and real values should result in
> 0.  

I think that 1/0, for real values, should result in Inf now.
1. The compiler will have to do it eventually, anyway; the 4.10 spec
   requires it.
2. This does not differ from the compiler's previous
   behavior (previous, as in before my patches). The compiler constant-
   folded floating point ir_binop_div, ir_binop_mod, and ir_unop_rsq to
   inf when the denominator was 0.
3. Doing so now will not diverge from specified behavior, since the
   previous specs are lenient here [1].

> This also applies to e7c1f058.

I'll revert b3cf92 and fix e7c1f058 so that integer valued 1/0 results
in 0. Once we decide how to resolve real valued 1/0, I'll fix e7c1f058
in those cases too.

- ----
[1] OpenGL 3.3 spec, page 20 (page 26 of PDF): "Similarly, treatment of
conditions such as divide by 0 [for floating point numbers] may lead to
an unspecified result, but in no case should such a condition lead to
the interruption or termination of processing."

- -- 
Chad Versace
chad at chad-versace.us
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJNSfxOAAoJEAIvNt057x8iFS8P/0bHWeucfwahYH10bpz8QxeA
YK9vdRmyXyNcxYNniR5wHbm7RqtGOgS80KDRBWzBFTQ1yqdgJFatQmcP8T7djlrh
nmdO429fqUoTOdHofdPJaFVKETkGO1HLar6FRE+yi/ybCFejhgHEGTWQzRL55vaS
NQtk3qXiDTWx1Y9qCef622bfcriCEWDklGJjQ1CQnNpGAbPDX1dMce7c283H5bet
zUdsvb9yASVKIXNkWG1zb0PMxt8ClOHcWWtc+jDtYdKSnly/f4BV/WljHx3MNDPy
xtn5OhVNDxlq64XBduKeoEe6nF3chfWyB2Hoj/M/LZqz9weSubUuEQiOn3iZGXut
Z3oItU/3+PDDDN09GAQM61PaW1bpphM9B6lysz1c086KYut7o8H0IdNe+2sxH8aS
pF+qdJRskjRXAwRhWBLVEO0fJEUcZgyeFkBOCd0XhJMZLXq1QyipArKhGo+J48jx
Z/XuSuHYiwz4ypVk76ijhMoutSr+6BM9G5io4CMjYR9Pz1Sbe2c5zQDPGKVU6wt4
tORqlb4MosqIHq65aSMr9n6Apr509CuYl7uVS/s4IPxC2QbOHX3ttZRp9y4HSk0i
oLSdVKYrrvUg1IovFDCaHNy7rqV2DI8wlpnlsDIO8JDtXRmDlPnLQnJXnHPyDIzi
cvTckj4ybkXryAbaaZFz
=o718
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list