This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
CSE insufficiency
- From: Luchezar Belev <l_belev at yahoo dot com>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 8 Feb 2005 16:07:12 -0800 (PST)
- Subject: CSE insufficiency
Hi all,
It seems that GCC does not recognize that the two expressions
`k*k+k' and `k*(k+1)' are identical (here k is int).
for example the generated code for
int f(int k) { return (k*k+k) == (k*(k+1)); }
does the full calculation, whereas the generated code for
int f(int k) { return (k*k+k) == (k*k+k)); }
directly returns 1
I think this is a very fundamental optimization.
I felt even more disappointed when i checked and found that other
compilers manage to do it, namely intel's icc and the microsoft's
compiler.
Regards,
Lucho
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com