> I've always wondered, is it imaginable that a compiler would be able to
> do such transforms (assuming very intelligent people (i.e. not me)
> have plenty of time to work on it), or is it way too complicated ?
Spotting more patterns would require more code in the compiler, and it
would increase compile times.
So one has to decide whether the cost is worth the benefit.
Apparently, so far it has not been considered worthwhile.