Re: Evolution of PL/I



Tom LINDEN wrote:
On Wed, 24 May 2006 19:51:31 -0700, John W. Kennedy <jwkenne@xxxxxxxxxxxxx> wrote:

Tom LINDEN wrote:
On Wed, 24 May 2006 12:21:14 -0700, glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx> wrote:

I wrote this one thinking that changes to L would take effect within
the loop, but in any case with the ABS the compiler can be sure that the increment is never negative, and optimize accordingly.

Doesn't matter, the optimization is the samer anyway.

It can't be the same. The /meaning/ of BY depends on the sign.

doesn't matter. either it is a constant or it is an expression. You
create the trees and the optimizer will do what it can, maybe fold constants,
create shadow variables, many things. You may end up generating differnet instructions sequences depending on the architecure. VAX had, for example,
a single instruction that did, add compare and branch. On risc machines
it is more cumbersome

The problem is that what comparison is done depends on the sign of the BY. In principle, a compiler that knows that the BY is positive (or negative) can create a single test and branch. A compiler that does not know the sign of BY must either use a special add-and-compare-and-branch-if-high-if-addend-is-positive-or-branch-if-low-if-addend-is-negative instruction (I don't know of any architecture that includes one), or else must use two nested branches, or play around with something like the EX instruction or a nested subroutine call, any one of which is likely to upset pipelining.

On any machine I know, 'BY ABS(expression)' is theoretically capable of better optimization, possibly massively better optimization, than is 'BY expression', except where 'expression' is UNSIGNED.

--
John W. Kennedy
"The blind rulers of Logres
Nourished the land on a fallacy of rational virtue."
-- Charles Williams. "Taliessin through Logres: Prelude"
.



Relevant Pages

  • Re: Java outperforms C++?
    ... > overlapped it is stopping some other instruction from overlapping. ... > Which C++ compiler uses GC? ... optimization is difficult and expensive. ... Decoupling the optimization from execution allows the optimization to ...
    (microsoft.public.vc.language)
  • Re: Evolution of PL/I
    ... Doesn't matter, the optimization is the samer anyway. ... a compiler that knows that the BY is positive can create a single test and branch. ... instruction, or else must use two nested branches, or play around with something like the EX instruction or a nested subroutine call, any one of which is likely to upset pipelining. ... On any machine I know, 'BY ABS' is theoretically capable of better optimization, possibly massively better optimization, than is 'BY expression', except where 'expression' is UNSIGNED. ...
    (comp.lang.pl1)
  • Re: Powerpc optimization change the order of operation
    ... optimization in the compiler. ... The compiler is not allowed to change the order of volatile accesses, ... As well as all the above good advice, it's important to remember that "volatile" is an instruction to the compiler, not the processor. ...
    (comp.arch.embedded)
  • Re: Evolution of PL/I
    ... a compiler that knows that the BY is positive can create a single test and branch. ... instruction, or else must use two nested branches, or play around with something like the EX instruction or a nested subroutine call, any one of which is likely to upset pipelining. ... On any machine I know, 'BY ABS' is theoretically capable of better optimization, possibly massively better optimization, than is 'BY expression', except where 'expression' is UNSIGNED. ... It certainly matters on some hardware whether a tight loop has a conditional branch in the middle of it, and, for the rest, you seem to be saying "all optimizers are perfect". ...
    (comp.lang.pl1)
  • Re: Brian Kernighan, maybe Im not worthy, maybe Im scum
    ... what experienced programmers do, ... optimization, ... Thugs" ad nauseum fits that a lot more closely than discussing compiler ... be modified outside a loop, and guessing ...
    (comp.programming)