Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!cornell!rochester!PT.CS.CMU.EDU!sei!sei.cmu.edu!firth From: firth@sei.cmu.edu (Robert Firth) Newsgroups: comp.lang.c Subject: Re: 16x16 = 32 Message-ID: <2884@aw.sei.cmu.edu> Date: Fri, 16-Oct-87 09:24:23 EDT Article-I.D.: aw.2884 Posted: Fri Oct 16 09:24:23 1987 Date-Received: Sat, 17-Oct-87 20:09:14 EDT References: <143@kesmai.COM> Sender: netnews@sei.cmu.edu Reply-To: firth@bd.sei.cmu.edu.UUCP (Robert Firth) Organization: Carnegie-Mellon University, SEI, Pgh, Pa Lines: 33 In article <143@kesmai.COM> dca@kesmai.COM (David C. Albrecht) writes: >In virtually every machine I know of the multiplies produce a >double width result (PDP-11, VAX, 68000, 8?86, ad nauseum) (1) On the PDP-11, the MUL instruction produces a single-length result if the destination is an odd-numbered register, and a double-length result if it's an even-numbered register (2) On the Vax-11, the MULx instructions all produce single-length results. A double-length result requires either first widening byte or word, or using EMUL for longword. (3) On the MC68020, the result of MULS is either single-length or double-length, depending on the Sz field of the instruction; the lower members of the range do not have a hardware 32-bit multiply. And with that piece of gratuitous misinformation out of the way, to the point. The task of a compiler is not to provide a more readable form of the machine's instruction set. It is to implement the language as defined in the standard. If the standard says that int*int => int, then that's what you implement, and anything else is plain WRONG. If the standard says you are allowed to keep intermediate results to higher range or precision, then you may do so; but you would be well advised to understand the consequences - in particular, that seemingly harmless changes to a working program, like taking an expression out of line, or doing common subexpression elimination by hand, may break a working program. When in doubt, implement the canonical semantics. At the very least, it is a courtesy that will be appreciated by the user who has taken the trouble to read the reference manual.