Make the 2-address instruction lowering pass smarter in two ways:
authorChris Lattner <sabre@nondot.org>
Sun, 2 Jan 2005 02:34:12 +0000 (02:34 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 2 Jan 2005 02:34:12 +0000 (02:34 +0000)
commitcfa0f2edd31a32d58ffa6e5224c6f476932d82b5
treeaed6caa1f80aaca4916e876bba5e8201357255bb
parentae37c2a543642b0b3a8b5f082fd12d9ec281aad4
Make the 2-address instruction lowering pass smarter in two ways:

1. If we are two-addressing a commutable instruction and the LHS is not the
   last use of the variable, see if the instruction is the last use of the
   RHS.  If so, commute the instruction, allowing us to avoid a
   register-register copy in many cases for common instructions like ADD, OR,
   AND, etc on X86.
2. If #1 doesn't hold, and if this is an instruction that also existing in
   3-address form, promote the instruction to a 3-address instruction to
   avoid the register-register copy.  We can do this for several common
   instructions in X86, including ADDrr, INC, DEC, etc.

This patch implements test/Regression/CodeGen/X86/commute-two-addr.ll,
overlap-add.ll, and overlap-shift.ll when I check in the X86 support for it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19245 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/TwoAddressInstructionPass.cpp