Boost logo

Boost :

From: Greg Colvin (Gregory.Colvin_at_[hidden])
Date: 2002-08-22 00:29:51


At 09:30 PM 8/21/2002, Maxim Shemanarev wrote:
>> If the committee is seriously considering ways to handle stuff, how about
>> dealing with the two results returned by almost every integer divide
>> instruction... quotient and remainder.
>
>Right. That's another thing. But in this case if you write x=a/b; y=a%b; a
>compiler at least *can try* to optimize this. In case of x*a/b it cannot
>because it's not allowed to! The question is really not a technical one. We
>really don't have a choice even if we were the ANSI committee.

Really?

For the following code

   typedef unsigned __int32 uword;
   typedef unsigned __int64 ulong;

   ulong mul(uword a, uword b, uword c) {
      return (ulong)a * b;
   }

the old C compiler on my machine emits

   mov eax, DWORD PTR _b$[esp-4]
   mul DWORD PTR _a$[esp-4]

which is as good as it gets.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk