Path: utzoo!utgpu!attcan!uunet!husc6!bloom-beacon!tut.cis.ohio-state.edu!cwjcc!gatech!udel!rochester!srs!dan
From: dan@srs.UUCP (Dan Kegel)
Newsgroups: comp.lang.c
Subject: Multiplying two shorts...
Message-ID: <948@srs.UUCP>
Date: 10 Aug 88 18:18:51 GMT
Reply-To: srs!dan@cs.rochester.edu (Dan Kegel)
Organization: S.R.Systems
Lines: 16

Sun's compilers seem to let you multiply two short integers and get all 
32 product bits, if you code like this:
    register short x, y;
    register long z;

    z = x * y;

If the compiler is nice, it emits the correct (16x16=32) multiply instruction.
If it isn't nice, it emits the slower (32x32=64) instruction and throws
away the top 32 bits.

Do most modern compilers perform this optimization?
It would be nice to be able to depend on it.
-- 
  Dan Kegel   "We had to get it passed before the columnists attacked!"
  srs!dan@cs.rochester.edu  rochester!srs!dan dan%srs.uucp@harvard.harvard.edu