There have been compilers that did this optimization.
179.art, one of the SPEC2000 benchmarks, has some poorly laid out structs. Sun Microsystems was the first company to introduce targeted optimizations for this benchmark.
GCC also had an optimization pass[0] for this. It may have been removed.
[0] https://www.research.ibm.com/haifa/dept/_svt/papers/golovane...