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

Re: [PATCH] Constant fold -A - B as -B - A (take 2)


    Is your use of the word "legal" based upon C/C++ standards?  My
    understanding was that the semantics of expressions at the tree
    level were supposed to be independent of the front-ends, and that
    if an operation is undefined in some subset of front-ends then
    choosing a behaviour that's consistent across the others is a
    reasonable prerogative.

There is *no* language, as far as I know, for which MAX_INT + 1 is defined,
let alone equal to MIN_INT.  So GCC is entitled to assume that EXP + 1 > EXP,
for example.

If you make that assumption, then you can implement some optimizations that
are unsafe if that assumption weren't true.  Your point is that making that
assumption means you can't make some other set of optimizations.  The
question then becomes which of the two sets of optimizations is of the most
value for real programs.  Only measurements can answer that question
definitively, but if I had to guess, I'd say that making the assumption
that it won't overflow will have the most benefit in real programs (due to
loop optimizations).


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