SignΒΆ

Originally the result of sign(x) would be:

-1 if x < 0,
1 if x > 0

and

0 if x == 0

However, if the last case is not needed it is better to use conditional form instead of sign().

fragColor.x = sign(t.x) * t.y; // three cycles
{mov, pck, tstgez, mov}
{mov, pck, tstgez, mov}
{sop, sop}
-->
fragColor.x = (t.x >= 0.0 ? 1.0 : -1.0) * t.y; // two cycles
{mov, pck, tstgez, mov}
{sop, sop}

// Instructions on Volcanic:
fragColor.x = sign(t.x) * t.y;
p0 = res>0
{movc}
p0 = i0 < 0f (sc0)
{movc}
 -->
fragColor.x = (t.x >= 0.0 ? 1.0 : -1.0) * t.y;
p0 = res>=0
{movc}