pinskia at gcc dot gnu dot org wrote:
This particular case is trivial to fix inside the tree optimizers. Variable 'i' is a local variable with static storage that is not upward exposed (i.e., it has no default definition).void g(); int f(int s, int *a) { static int i; for (i = 0; i < 800; i++) { g(); s += a[i]; } return s; }
But all of this needs to be on the tree level to be really effective.
Once you recognize that, you can safely flip the TREE_STATIC bit on the variable and expose it as a gimple register.
Diego.