This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/34503] Issues with constant/copy propagation implementation in gcse.c
- From: "steven at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Dec 2007 08:38:13 -0000
- Subject: [Bug rtl-optimization/34503] Issues with constant/copy propagation implementation in gcse.c
- References: <bug-34503-280@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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