This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix optimization regression in constant folder
On 10/11/07, Richard Kenner <firstname.lastname@example.org> wrote:
> > Yes. What makes Ada somewhat special is that it is quite common for Ada that
> > those are not integer constants (of sizetype), but variables or
> > expressions (of sizetype).
> No. If you have a[i], in any language, the computation of the offset from
> the start of A is done in sizetype and that's normally an expression.
> It's certaily true that you can have *more complex* sizetype expressions
> in Ada than in C, but that's relative and Mark's example yesterday showed
> that sizetype expressions can be even more complex in C++ than Ada.
> We're seeing the *optimization* issue more in Ada because very long
> expressions occur more there, but the definitional issue is very much
> language-independent, which is what many of us have been trying to
> explain for a while.
Sure. Just we didn't see the optimization issue in C code (yet). Of course
a C testcase is even more appreciated than an Ada one ;)
Another difference that might contribute to this optimization difference between
C and Ada is that appearantly sizetype in Ada is signed compared to other
languages where it is unsigned. Now, if it is a great idea to allow the FEs to
specify signedness of a middle-end internal type is another question ;)
So I propose to define all sizetypes as having undefined overflow (the same
as for pointers) as this will likely cause the least problems with mismatched
semantics of involved types in expressions. If we do that we should see the
optimization issues in C as well.