Re: Implementation dependent behaviour (WAS: Re: Programming language and IDE design)

anton@mips.complang.tuwien.ac.at (Anton Ertl)
Tue, 14 Jan 2014 14:16:44 GMT

          From comp.compilers

Related articles
[5 earlier articles]
Re: Implementation dependent behaviour (WAS: Re: Programming language martin@gkc.org.uk (Martin Ward) (2014-01-06)
Re: Implementation dependent behaviour (WAS: Re: Programming language ivan@ootbcomp.com (Ivan Godard) (2014-01-08)
Re: Implementation dependent behaviour (WAS: Re: Programming language kaz@kylheku.com (Kaz Kylheku) (2014-01-08)
Re: Implementation dependent behaviour (WAS: Re: Programming language ivan@ootbcomp.com (Ivan Godard) (2014-01-10)
Re: Implementation dependent behaviour (WAS: Re: Programming language gah@ugcs.caltech.edu (glen herrmannsfeldt) (2014-01-10)
Re: Implementation dependent behaviour (WAS: Re: Programming language ivan@ootbcomp.com (Ivan Godard) (2014-01-13)
Re: Implementation dependent behaviour (WAS: Re: Programming language anton@mips.complang.tuwien.ac.at (2014-01-14)
| List of all articles for this month |

From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.compilers
Date: Tue, 14 Jan 2014 14:16:44 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
References: 13-11-025 14-01-007 14-01-008 14-01-011
Keywords: arithmetic, standards, C
Posted-Date: 14 Jan 2014 12:14:37 EST

glen herrmannsfeldt <gah@ugcs.caltech.edu> writes:
>It has been hardware tradition for a long time to offer double width
>product on multiply and dividend on divide, but rare for high-level
>languages to allow for its use.
>
>I believe that gcc recognizes casts to (long long) on the operands of
>multiply to generate a single multiply instruction with a double
>length product. (That is, it doesn't do the three multiplies by zero
>that the casts imply.) I don't know about divide.


Yes, gcc does that for multiplication (suitably written in C, posted
elsewhere in this thread). It cannot do this for divide, because
there is no way to express the operation in C (boundary conditions
like overflow don't match).


>I have at times needed to multiply two 32 bit values, for a 64 bit
>product, then divide by another 32 bit value. I sometimes hope that
>the compiler figures it out.


No, it won't. Better use a language that can express this. Forth has
*/, which does exactly this sequence of operations; it also has
double-by-single division words, as well as
single-by-single-giving-double multiplication words.


- anton
--
M. Anton Ertl
anton@mips.complang.tuwien.ac.at
http://www.complang.tuwien.ac.at/anton/


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.