Patent ID: 8910114

Claim:
A method comprising: identifying, using a compiler executing on a processor of a computer system, a byte swap operation; building, using the compiler, a domain including the byte swap operation and other expressions, wherein the other expressions are connected swap tolerant expressions that extend the domain, and identifying domain entries and domain exits associated with the domain; determining, using the compiler, that a benefit will be obtained by performing a swap of the domain based on profiling information stored in a performance monitor table during a first compilation pass, including calculating the benefit by determining that an amount of code removed from the domain minus an amount of code inserted to the domain is greater than a threshold, and responsive to the determination performing the swap of the domain during a second compilation pass, wherein performing the swap of the domain includes changing a byte order of at least some of the associated domain entries and domain exits, and substituting expressions in the domain with counterpart operations that operate in a different byte order, and removing a byte swap operation from a first expression and inserting a byte swap operation into a second expression, wherein the first expression is of a hotter path than a path of the second expression; and storing the swapped domain in a storage medium of the computer system.