Skip to content

glsl: replace 'x + (-x)' with constant 0

Pierre-Eric Pelloux-Prayer requested to merge pepp/mesa:fix_111241 into master

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

   value -= value

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

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111241


Questions:

  • I'm not sure if this is the correct place to implement this?
  • maybe a better fix would be to ask LLVM to not emit NaN in this case, but a more sensible value (0 ?). But maybe this doesn't make sense from the compiler perspective.

v1: implemented for tgsi

v2: implemented in glsl/opt_algebraic.c

Edited by Pierre-Eric Pelloux-Prayer

Merge request reports