Re: LDD and STD on RISC (Rick Gorton)
Mon, 9 Mar 1992 20:30:35 GMT

          From comp.compilers

Related articles
LDD/STD Optimizations (1992-03-03)
Re: LDD and STD on RISC (1992-03-09)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Rick Gorton)
Keywords: optimize, sparc
Organization: Compilers Central
References: 92-03-018
Date: Mon, 9 Mar 1992 20:30:35 GMT

Preston Briggs ( writes:
>[LDD & STD a mistake for RISC machines: compilers can't generate 'em.]

David Keppel ( write:
>I expect if you have lots of fp values and ldd and std are used for
>floating-point values then you don't need any more justification for
>having ldd and std. Of course most RISC machines load and store fp regs
>using different load and store instructions.
>The compiler can also use `ldd' and `std' to advantage when doing spills
>and restores for both calle-save and caller-save registers (in general for
>any spills and restores). Easiest is to do register allocation the normal
>way, then do trivial register renaming to get the registers in adjacent
>pairs. The stack spill slots need to be renamed and possibly realigned;
>that ``should'' be straightforward. DECstation (MIPS) compilers already
>do such an optimization some of the time. Putting spills and restores in
>adjacent memory locations also improves caching.

And in fact, there are some other tricks which can be done:

On some RISC machines, (I'll stick to SPARC, since that was the originally
cited architecture) LDD and STD require that the memory locations being
accessed are 0 mod 8 (quadword) aligned, and that the first register of
the pair is an even numbered register. Combine this with the fact that
%fp and %sp are ALWAYS 0 mod 8 valued, one can transform the following
LD/ST sequences:

(Presuming that offset1 is 0 mod 8 valued, and <n> even).
LD [%fp+offset1], %R(n) LD [%fp+0x8], %l0
LD [%fp+offset1+4], %R(n+1) LD [%fp+0xC], %l1

ST %R(n), [%fp+offset1] ST %g2, [%fp+0x8]
ST %R(n+1), [%fp+offset1] ST %g3, [%fp+0xC]

LDD [%fp+offset1], %R(n) LDD [%fp+0x8], %l0
STD [%fp+offset1], %R(n) STD [%fp+0x8], %g2

Thus, even if %fp+0x8 and %fp+0xC contain different variables, LD/LD can
be replaced by LDD. This actually happens only rarely, unless an
optimization like the MIPS one described above is happening, or there is
some inherent datatype in the compiler which uses pairs of integer
registers, like INTEGER*8 in FORTRAN, or PIC 9(18) (I think this is the
syntax) in COBOL.

Richard Gorton (508) 626-0006
Liant Software Corp. Framingham, MA 01760 USA
Project leader: LPI-BASIC, LPI-FORTRAN, LPI-Pascal, LPI-PL/I

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.