RTL-level loop invariant motion.
Copyright (C) 2004-2024 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.
GCC is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>.
This implements the loop invariant motion pass. It is very simple
(no calls, no loads/stores, etc.). This should be sufficient to cleanup
things like address arithmetics -- other more complicated invariants should
be eliminated on GIMPLE either in tree-ssa-loop-im.cc or in tree-ssa-pre.cc.
We proceed loop by loop -- it is simpler than trying to handle things
globally and should not lose much. First we inspect all sets inside loop
and create a dependency graph on insns (saying "to move this insn, you must
also move the following insns").
We then need to determine what to move. We estimate the number of registers
used and move as many invariants as possible while we still have enough free
registers. We prefer the expensive invariants.
Then we move the selected invariants out of the loop, creating a new
temporaries for them if necessary.
The data stored for the loop.