Question about regrouping of operands

Doug Gwyn gwyn at brl-smoke.ARPA
Sun May 22 01:17:18 AEST 1988


In article <19000 at watmath.waterloo.edu> rbutterworth at watmath.waterloo.edu (Ray Butterworth) writes:
>Now if integer overflow checking is enabled, the compiler is
>no longer free to do the additions in any order it wants.  It
>must do them in precisely the order that the programmer has
>requested, since the programmer might have specificly requested
>that order to prevent overflow.

This is correct.  However, it has not been demonstrated that a
serious loss of efficiency will necessarily result from removal
of this kind of optimization.  The only way I can imagine it being
significant would be for the hardware to provide extremely poor
data caching (for example, only a couple of data registers) so
that the compiler is forced to resort to more expensive caching
(for example, via push/pop).  My feeling is that people with
hardware like that already have much worse problems to worry about.

>With this change to the order of additions, the world will again
>lose out on compilers that help us to write more reliable code.

Overflow checking does not help in the writing of more reliable
code, but rather in the detection of unreliable code at a hard-to-
predict moment during actual execution.  There are certainly cases
in which I would prefer such an application to keep running even
with a slightly wrong behavior rather than simply fault.

>I'll never understand why they did it.

I can't help you there.



More information about the Comp.std.c mailing list