PR #62322 disabled the balanced dispatch switch optimization for floating-point input types.
Instead of giving up on the optimization entirely for benefit of correctness, we could choose to produce a not-quite-balanced switch dispatch (offering some performance benefits of somewhat balancing) while maintaining the NaN case on the rightmost edge (all false path).
Another possibility might be to force and explicit NaN check at the top, then balance the tree below that.