diff --git a/src/r_main.h b/src/r_main.h index ef0a8c3bc..8b93ec755 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -116,9 +116,10 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y -= ly; // Try to quickly decide by looking at sign bits. - if ((ldy ^ ldx ^ x ^ y) < 0) - return (ldy ^ x) < 0; // (left is negative) - return FixedMul(y, ldx>>FRACBITS) >= FixedMul(ldy>>FRACBITS, x); + // also use a mask to avoid branch prediction + INT32 mask = (ldy ^ ldx ^ x ^ y) >> 31; + return (mask & ((ldy ^ x) < 0)) | // (left is negative) + (~mask & (FixedMul(y, ldx>>FRACBITS) >= FixedMul(ldy>>FRACBITS, x))); } angle_t R_PointToAngle(fixed_t x, fixed_t y);