"for" loops in C ...

Henry Spencer henry at utzoo.uucp
Thu Nov 10 03:42:57 AEST 1988


In article <339 at igor.Rational.COM> dsb at Rational.COM (David S. Bakin) writes:
>I don't get it.  The operator << is defined in C as a left shift, what
>does that have to do with a particular VAX instruction, ASHL, that happens
>to mask its operand to the low-order 5 bits.  Doesn't this merely mean that
>on the VAX when the argument of the left shift is not a known constant that
>the single instruction ASH sequence must be replaced by a multiple instruction
>sequence that does the right thing?

The point is precisely that one would prefer to avoid this, for the sake
of (whisper it) efficiency.  There are quite a number of places where the
semantics of C are deliberately machine-specific, to permit implementors
to do things the most efficient way rather than having to take a performance
hit from doing them a standard way.  Such flexibility is generally made
available either because the efficiency impact of not doing so is major
(e.g. size of int) or because the semantics appear to be unimportant for
well-written programs (e.g. the order of side effects in an expression).
Shift counts equal to the word size are generally considered a case of
the latter, with some of the former stirred in.
-- 
The Earth is our mother.        |    Henry Spencer at U of Toronto Zoology
Our nine months are up.         |uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list