|Re: What is the FORTRAN for ? firstname.lastname@example.org (1990-07-30)|
|Re: What is the FORTRAN for ? email@example.com (Preston Briggs) (1990-07-30)|
|Re: What is the FORTRAN for ? firstname.lastname@example.org.OZ.AU (1990-07-31)|
|Re: What is the FORTRAN for ? email@example.com (Bart Massey) (1990-08-01)|
|From:||Preston Briggs <firstname.lastname@example.org>|
|Keywords:||Fortran, optimize, code|
|Organization:||Rice University, Houston|
|References:||<1990Jul25.email@example.com> <164@kaos.MATH.UCLA.EDU> <firstname.lastname@example.org>|
|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
>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
Return to the
Search the comp.compilers archives again.