OT (partially): about promotion of integers
eles
eles at eles.com
Wed Dec 12 09:03:08 PST 2012
On Wednesday, 12 December 2012 at 14:39:40 UTC, Michael wrote:
> Machine/hardware have a explicitly defined register size and
> does know nothing about sign and data type. fastest operation
> is unsigned and fits to register size.
Frankly, the hardware knows nothing about classes and about
virtual methods, neither.
The question is: why the DEVELOPER should know about that
register size? There are many other things that the developer is
unaware of (read SSE instructions) and those are optimized behind
his back.
The choice to promote to the fastest type is a sweet thing for
the compiler, but a burden for the developer.
OTOH, I *never* asked for compulsory promotion, just mimicking
it. (in fact, I was not asking for anything, just addressed a
question) The idea is to guarantee, by the compiler, that the
final result of an integral arithmetic expression is AS IF all
integrals there are promoted to some widest-integral type.
Actual promotion would be made only if the compiler believes
that's really necessary.
In the current implementattion too, speed is lost as long as you
have a long there, as you need promotion further than int.
More information about the Digitalmars-d
mailing list