This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/24669] Loop index variable has offset of 1



------- Comment #2 from rakdver at gcc dot gnu dot org  2005-11-04 10:35 -------
There are two reasons we do not produce the code as in the comment #1:

1) This would require reversing the loop, which is currently implemented in
mainline only in old loop optimizer, in a very weak fashion. More powerful
implementation is in killloop branch and should appear in 4.2.
2) Nevertheless, in this particular example we cannot reverse the loop at all
(i.e., the proposed code is incorrect) -- it would cause misscompilations for
example if foo is called as foo(p + 1, p).  If p = {1,2,3,4,5}, the original
code sets it to {1,1,1,1,1}, while the new one to {1,1,2,3,4}.

The fact that the index variable is chosen to start with 1 instead of zero is
more interesting.  It does not really matter that much, since both
possibilities have exactly the same cost.  But the reason is that target
description pretends that the more complicated addressing mode is in fact
cheaper, thus misguiding ivopts to prefer it to the simpler one, if everything
else is equal.


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]