GLSL function used to differentiate between pixels above/below a line
I would try using the dot product for your test. If you take the vector from p1 to p2 and form the dot product with the vector from p1 to aspect, it will return the cosine of the angle between them. The cosine of an angle is positive when the angle is between -90° and 90° and it's negative when the angle is in the other 180° of the circle. What this means is that when aspect falls on one side of the line it will be positive and on the other it will be negative. So your function could be rewritten as something like this:

float slice(vec4 aspect, vec2 p1, vec2 p2, bool top) {
    aspect /= aspect.w;    // &lt;- may be unnecessary if w is guaranteed to be 1.0
    vec2 v1 = aspect.xy - p1;
    vec2 v2 = p2 - p1;
    float cosTheta = dot(v1, v2);
    float result step(0.0, cosTheta);
    return top ? result : 1.0 - result;
}


I haven't tested this, but it removes all conditionals and logical operators. If you don't need the divide by w then there are no divisions, either. I think this could be faster, but you'll need to profile to be sure.

Note that this assumes that "on the line" can be taken as being on one side or the other. If you need to differentiate that case, I think you'll need either a conditional or some clever non-conditional code to extract that case.