[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

155.0. "A compiler "optimization"" by HARE::STAN () Fri Sep 21 1984 04:02

Most compilers would compile A*B+C/D as

	LOAD A
	MULTIPLY B
	STORE TEMP
	LOAD C
	DIVIDE D
	ADD TEMP

Show how to do this in one instruction less, using the same
instruction repertoire.  Explain why real-world compilers don't do
it that way.
T.RTitleUserPersonal
Name
DateLines
155.1ADVAX::J_ROTHFri Sep 21 1984 15:5415
clearly, A*B + C/D = (A*B*D + C)/D

	load a
	mul b
	mul d
	add c
	div d

I'd think there could be artifacts due to the increased dynamic range of
values possible in the temporary expression A*B*D vs A*B only.


Besides, you have more than 1 register available for fast temporaries.

- Jim
155.2CHAMP::BILLFri Sep 21 1984 16:355
Besides, why do another multiply?  Multiply and divide are usually slower
than move.

piper
155.3ORPHAN::BRETTSun Sep 23 1984 03:004
Besides, its an uncommon case

/Bevin
155.4TURTLE::GILBERTSun Sep 23 1984 03:433
Overflow is also a possibility.

Besides, if that's what the programer wanted, he should've written it that way.