This is the mail archive of the gcc@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]

loop-2b and such



Joseph Meyers has pointed out that loop-2b fails when optimizing and
using -mcpu=k6.  (It did not with GCC 2.95.)  The problem is that we
replace a GIV in an invalid way.  It works by dumb luck on an ordinary
x86 because we think the cost of the replacement is too high.

The basic problem is that we change `a < b' where `a' and `b' are
integers into `&x[a] < &x[b]' and the array is sufficiently large that
`x[b]' is at a numerically smaller address than `x[a]'.  The bottom
line is that our optimization is entirely broken in this respect; we
have no business making this transformation unless we can prove that
the result will be the same.  (One thing we could do in this case is
note that `a' is incremented each time through the loop, and replace
the test with `!=' rather than `<'.  Then, the replacement would be
valid.

However, my recollection is that we have always been broken in this
respect, and the the behavior of the loop-[23]*.c tests oscillate
essentially randomly depending on other things in the compiler.  In
this sense, the term "regression" is somewhat bogus.  On the other
hand, we have in fact broken a piece of legal C code.  The only fix I
can imagine, however, is entirely eliminating GIV replacement, which
is not a good decision.  So, I propose to simply ignore the failures
for the release, and to file a bug report about the underlying
problem.

Thoughts?

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com


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