The Design and Application of a Retargetable Peephole Optimizer

  • Authors:
  • Jack W. Davidson;Christopher W. Fraser

  • Affiliations:
  • Department of Computer Science, University of Arizona, Tucson, AZ;Department of Computer Science, University of Arizona, Tucson, AZ

  • Venue:
  • ACM Transactions on Programming Languages and Systems (TOPLAS)
  • Year:
  • 1980

Quantified Score

Hi-index 0.00

Visualization

Abstract

Peephole optimizers improve object code by replacing certain sequences of instructions with better sequences. This paper describes PO, a peephole optimizer that uses a symbolic machine description to simulate pairs of adjacent instructions, replacing them, where possible, with an equivalent single instruction. As a result of this organization, PO is machine independent and can be described formally and concisely: when PO is finished, no instruction, and no pair of adjacent instructions, can be replaced with a cheaper single instruction that has the same effect. This thoroughness allows PO to relieve code generators of much case analysis; for example, they might produce only load/add-register sequences and rely on PO to, where possible, discard them in favor or add-memory, add-immediate, or increment instructions. Experiments indicate that naive code generators can give good code if used with PO.