glsl: replace 'x + (-x)' with constant 0
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Wed, 28 Aug 2019 08:56:52 +0000 (10:56 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 29 Aug 2019 21:48:49 +0000 (17:48 -0400)
commit47cc660d9c19572e5ef2dce7c8ae1766a2ac9885
tree283bb3e3eb0ee592d2e8aa5806b2f0e053442a98
parent8d03a6b70072858a7acb7ce92bcf26f9a69dee2d
glsl: replace 'x + (-x)' with constant 0

This fixes a hang in shadertoy for radeonsi where a buffer was initialized with:

   value -= value

with value being undefined.
In this case LLVM replace the operation with an assignment to NaN.

Cc: 19.1 19.2 <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111241
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/compiler/glsl/opt_algebraic.cpp