You can design the language to make such transforms more transparent without resorting to special 'compiler optimization magic'.
For instance Zig has a MultiArrayList container in its stdlib which slices its generic item type into one array for each struct item. This isn't a special compiler feature, but a regular usage of Zig's comptime stuff:
https://github.com/ziglang/zig/blob/master/lib/std/multi_arr...