Compilers optimize data representation only when these two criteria are met:

  1. all relevant functions are inlined
  2. transformations have to be semantically reasonable
    • depends on the language, but an heuristic could be “data has to be on the stack”

If this happens, then an aggregate data structure can be exploded into its component parts, and optimized as if they were all local variables.

See also

References