A company like google has the resources to basically just make their interview an IQ test with the assumption that they can throw smart people into any role they need them in.
Seriously, we could get this done in three steps:
1. Phone screen including Fizzbuzz-level programming challenge.
2. IQ Test
3. Personality/Culture-fit interview.
You can get around this by conducting a study that finds IQ is better correlated to performance on a particular role than any other nondiscriminatory measure, but good luck with that, and good luck proving that when you get sued by someone. It's just too risky, despite not being illegal.
There is a popular myth that it is illegal because of a case where it was found to be illegal in the specific manner in which it was used.
https://www.hiresuccess.com/blog/is-employment-testing-legal