Skip to content
Snippets Groups Projects
Commit 8d4f8e7e authored by Marcin Ślusarz's avatar Marcin Ślusarz Committed by Dylan Baker
Browse files

glsl/opt_algebraic: disable invalid optimization

When operators other than eq and ne are involved we can't really
move operands around and negate them because such transformation
may change the value of the whole expression.

Some examples:

For unsigned var:
0 >= 1u + var would eventually become 0xffffffff >= var,
which would always evaluate to true, when original expression
was true only for var == 0xffffffff.

For signed var:
0 >= 1 + var would become -1 >= var, which would evaluate to
false for var == 2147483647, when original expression evaluated
to true (because signed overflow is defined to wrap around in
glsl, 1 + 2147483647 == -2147483648, so 0 >= -2147483648).

Closes: mesa/mesa#5226


Fixes: 34ec1a24 ("glsl: Optimize (x + y cmp 0) into (x cmp -y).")
Signed-off-by: default avatarMarcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: default avatarAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: default avatarIan Romanick <ian.d.romanick@intel.com>
Part-of: <mesa/mesa!12359>
(cherry picked from commit 89bc8ff4)
parent 40bdd9aa
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment