On 5/23/23 16:33, Richard Henderson wrote:

The tests are poorly ordered, testing many unlikely things before the most likely thing (normal).  A better ordering would be

     if (likely(tp##_is_normal(arg))) {
     } else if (tp##_is_zero(arg)) {
     } else if (tp##_is_zero_or_denormal(arg)) {
     } else if (tp##_is_infinity(arg)) {
     } else {
         // nan case
     }

Might also benefit from a is_finite (true if zero or normal or denormal) predicate, to do

if (tp##_is_finite(arg)) {
    if (!tp##_is_zero_or_denormal(arg)) {
       // normal
    } else if (tp##_is_zero(arg)) {
    } else {
       // denormal
    }
} else if (tp##_is_infinity(arg)) {
} else {
    // nan
}

since is_normal is a bit more complex and inefficient than the others. The compiler should easily reuse the result of masking away the sign bit.

Paolo


Reply via email to