Skip to content

glsl-1.30: Test range analysis of min and max in the presence of NaN

Ian Romanick requested to merge idr/piglit:review/range-analysis-minmax-NaN into main

Mesa currently fails both of these tests.

The range analysis of min(-abs(x), abs(y)) says that -abs(x) must be the result. However, if one parameter is NaN, min (and max) will always choose the parameter that is a number. Therefore, if x is NaN, the result will be abs(y).

Some optimizations use this knowledge to eliminate comparisons. Some examples:

   (('fge',  'a(is_lt_zero)',      'b(is_not_negative)'), False),
   (('flt',  'a(is_not_negative)', 'b(is_not_positive)'), False),

These reductions are "exact" if either a or b is NaN, but they are not exact if range analysis provides incorrect range information. 🤦

I have a fix in testing now.

@pendingchaos @hakzsam

Merge request reports