I haven't dealt with vector legalization, so this might not be the best or even correct approach. But I think this solves the motivating case from:
https://bugs.llvm.org/show_bug.cgi?id=38527
If we are legalizing an FP vector op that maps to 1 of the LLVM intrinsics that mimic libm calls, but we're going to end up with scalar libcalls for that vector type anyway, then we should unroll the vector op into scalars before widening. This avoids libcalls because we've lost the knowledge that some of the scalar elements are undef.
Please have a close look at the test diffs to make sure we didn't drop any necessary ops.