[Bug rtl-optimization/34503] Issues with constant/copy propagation implementation in gcse.c

steven at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Dec 17 08:38:00 GMT 2007



------- Comment #4 from steven at gcc dot gnu dot org  2007-12-17 08:38 -------
The global cprop pass prefers constants over copies.  Thus, when a copy is
found but a REG_EQUAL note for a constant is found on the same instruction,
only the constant is recorded.  This results in missed copy-propagation
opportunities.  A simple example probably shows best what I mean:

a = ...
if (...)
{
  a = 5;
  b = a; (REG_EQUAL 5}
}
else
{
  b = a;
}
c = b;

GCC will record "b = 5" on one arm of the if-then-else, and "b = a" on the
other.  Because each expression kills the other, "b = a" is lost and GCC would
fail to propagate "a" to give "c = a;".

[ The above example may seem trivial and non-realistic -- but with CSE
disabled, pre tree-ssa compilers actually do fail to optimize this! ]

To fix this, constants and copies have to be tracked simultaneously.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34503



More information about the Gcc-bugs mailing list