Related articles |
---|
Re: What is the FORTRAN for ? cik@l.cc.purdue.edu (1990-07-30) |
Re: What is the FORTRAN for ? preston@rice.edu (Preston Briggs) (1990-07-30) |
Re: What is the FORTRAN for ? ok@goanna.cs.rmit.OZ.AU (1990-07-31) |
Re: What is the FORTRAN for ? bart@videovax.tv.tek.com (Bart Massey) (1990-08-01) |
Newsgroups: | comp.compilers |
From: | Preston Briggs <preston@rice.edu> |
In-Reply-To: | <1990Jul30.180439.26627@esegue.segue.boston.ma.us> |
Keywords: | Fortran, optimize, code |
Organization: | Rice University, Houston |
References: | <1990Jul25.174153.16896@ecn.purdue.edu> <164@kaos.MATH.UCLA.EDU> <4922@munnari.oz.au> |
Date: | Mon, 30 Jul 90 22:59:41 GMT |
Herman Rubin writes:
>> double nint(double x)
>> {
>> return ceil(x + 0.5) - (fmod(x*0.5 + 0.25, 1.0) != 0);
>> }
>I have not checked the code, but this points out what is wrong with the
>present HLLs and that compilers cannot be expected to overcome the problem.
>If this #define were used, then this block of code would be inserted wherever
>this is wanted, even if there is a machine instruction which does the job.
>I do not see how a compiler can recognize that the complicated body of code
>can be replaced by a single instruction and make that substitution.
Sometimes these substitutions can be done via peephole optimizations. It's
particularly useful when the patterns are generated automatically from a
machine description (as in the work of Davidson and Fraser). The example
given looks sort of complex, but could easily be added by hand. The
usefulness of such effort depends on the instruction set of the machine -- for
a machine with quite complicated instructions, a lot of effort seems
justified.
>continue to crop up as long as the language primitives are restricted as
>they now are.
I'm up for interesting language primitives too, though perhaps for different
reasons. Consider Fortran's MAX and MIN functions. If they weren't provided
as functions, people would have to code them by hand, as if statements. But
the optimizer would rather see them as simple functions (expressions) so that
CSE elimination and loop invariant code motion can be performed. The same
idea is even more important when vectorizing compilers are used.
--
Preston Briggs looking for the great leap forward
preston@titan.rice.edu
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.