Address Register Assignment for Reducing Code Size

Mahmut T. Kandemir, Mary Jane Irwin, Guilin Chen, J. RamanujamCC 2003

Abstract

In embedded Digital Signal Processor (DSP) environments, code size and power consumption are critical constraints. A significant portion of DSP instruction sets is dedicated to address generation rather than core computation. This paper, originally presented at the 2003 International Conference on Compiler Construction, proposes a unified compiler framework designed to minimize explicit address register loads. By simultaneously optimizing data layout in memory and the sequence of operations in code, the framework maximizes the utilization of hardware-level auto-increment and auto-decrement addressing modes.

Introduction

In the design of embedded systems—particularly those utilizing DSPs from manufacturers like Motorola, Texas Instruments, and Analog Devices—memory is a scarce and expensive resource. Research indicates that up to 55% of instructions in typical DSP programs are dedicated to address arithmetic rather than data processing. To mitigate this, DSPs often include specialized Address Generation Units (AGUs).

AGUs allow for "free" pointer updates (incrementing or decrementing a register) when the next required data element is adjacent in memory to the current one. However, if the data access pattern is non-linear, the compiler must insert explicit instructions to load new addresses into the registers. These additional instructions increase the binary size and elevate power consumption. The objective of this research is to develop a strategy that allows the processor to "walk" through memory linearly, thereby reducing the need for expensive address manipulation.

The Unified Optimization Framework

While previous research addressed "Offset Assignment" (the arrangement of variables in memory) and "Code Restructuring" (the order of operations) as separate problems, this paper argues that these tasks are fundamentally codependent. The authors introduce a framework that integrates both strategies.

1. Memory Storage Reordering (Data Layout)

This component determines the optimal sequence for placing variables in memory. By placing variables that are accessed sequentially in adjacent memory slots, the compiler can leverage the AGU's auto-increment/decrement features.

2. Access Pattern Modification (Code Restructuring)

This component involves reordering instructions or operands within an instruction to better match the memory layout. The authors specifically exploit algebraic properties such as commutativity. For instance, because $a + b$ is equivalent to $b + a$, the compiler can choose the ordering that aligns with the current position of the address pointer, effectively gaining spatial locality without altering the program's logic.

Algorithmic Approach: LTG and CLTG

To manage the complexity of these simultaneous optimizations, the authors utilize two primary graph-based tools:

  • Layout Transition Graph (LTG): This graph maps the potential adjacencies between variables based on their access frequency.
  • Constrained Layout Transition Graph (CLTG): This is a refined version of the LTG that incorporates "legality" constraints. It ensures that any proposed reordering of instructions does not violate data dependencies (e.g., ensuring a "read" operation does not move before a "write" operation upon which it depends).

The optimization algorithm functions by identifying the "longest path" within these graphs, representing the maximum number of memory accesses that can be performed using only free auto-addressing modes.

Evaluation and Results

The framework was conceptualized with reference to standard benchmarks like the MediaBench suite and common DSP architectures such as the Motorola DSP56000 and TI TMS320C5x.

In a detailed walkthrough of a complex basic block, the authors demonstrated the efficacy of the unified approach:

  • Unoptimized Baseline: A standard access sequence required 8 explicit address load instructions.
  • Unified Optimization: The proposed framework reduced the cost to 4 explicit instructions.

This represents a 50% reduction in address-related code for that specific block. Such reductions directly contribute to smaller code footprints and improved energy efficiency in embedded hardware.

Limitations and Future Directions

Despite the performance gains, the authors note several challenges:

  • Computational Complexity: The core problem of finding the optimal offset assignment and the longest path in a graph is NP-complete. Consequently, the framework relies on heuristics to find near-optimal solutions within reasonable compilation times.
  • Register Constraints: The current logic focuses primarily on single address register optimization. Extending this to multiple registers increases complexity, as the compiler must then decide which register is best suited to track specific variables.
  • Future Work: The authors suggest exploring the impact of Static Single Assignment (SSA) form on these optimizations and developing more sophisticated methods for partitioning variables across multiple address registers.

Summary updated

BibTeX
@inproceedings{kandemir2003address,
  author = {Mahmut T. Kandemir and Mary Jane Irwin and Guilin Chen and J. Ramanujam},
  title = {{Address Register Assignment for Reducing Code Size}},
  booktitle = {CC},
  year = {2003},
  doi = {10.1007/3-540-36579-6\_20},
}
Figure