With the proliferation of embedded devices and systems, there is renewed interest in the generation of compact binaries. Code
compaction techniques identify code sequences that repeatedly appear in a program and replace them by a single copy of the
recurring sequence. In existing techniques such sequences are typically restricted to single-entry single-exit regions in
the control flow graph. We have observed that in many applications recurring code sequences form single-entry multiple-exit
(SEME) regions. In this paper we propose a generalized algorithm for code compaction that first decomposes a control flow
graph into a hierarchy of SEME regions, computes signatures of SEME regions, and then uses the signatures to find pairs of
matching SEME regions. Maximal sized matching SEME regions are found and transformed to achieve code compaction. Our transformation
is able to compact matching SEME regions whose exits may lead to a combination of identical and differing targets. Our experiments
show that this transformation can lead to substantial reduction in code size for many embedded applications.
Keywords Code compaction - single-entry-multiple-exit regions - control flow signature - predicated execution
Supported by grants from IBM, Intel, and NSF grants CCR-0105355, CCR-0208756, CCR-0220334, and EIA-0080123 to the Univ. of
Arizona.