From: utzoo!decvax!duke!harpo!seismo!dmy
Newsgroups: net.unix-wizards,net.lang.c,net.misc
Title: Why Does The C-Compiler Do This?
Article-I.D.: seismo.194
Posted: Tue Jan 11 14:42:22 1983
Received: Wed Jan 12 07:48:44 1983


I'm puzzled by an action of the (4.1absd) c-compiler.
Consider the fragments:

	int a,b;   a = 2  * 3  * b * 4;
	float a,b; a = 2. * 3. * b * 4.;

In the first case, it (intelligently) does one multiply of 24 by b.  In the
second case, it (poorly) does two multiplies, of 6. by b and the result by 4.
Why isn't the generated code exactly parallel?  Certainly the language allows
it, there's no question of overflow, and the expressions should be parsed and
code-generated in the same way.  Any comments?

--dmy--