sweetopt · rewrite library

Faster ways to write common shader math.

Every rewrite SweetOpt knows. Each one is checked: over its inputs' ranges the new form stays within a millionth of the original, or is closer to exact math, under every GPU's approximate math. SweetOpt applies them before its own search and checks the result again in each shader.

Savings are in fma units (1.0 = one fused multiply-add) from the cost models. Some rewrites only hold on the ranges listed under where; a few rely on float rounding and must be marked precise in the shader (SweetOpt does that).