Implement folding explicit load instructions into binary operations. For a
authorChris Lattner <sabre@nondot.org>
Mon, 8 Mar 2004 01:58:35 +0000 (01:58 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 8 Mar 2004 01:58:35 +0000 (01:58 +0000)
commit7dee5daf85b8a2a9ea8f5dc93923afad18dcc6a1
treea046c97276dd40e6df6f896ffbf6023dedb4bf22
parent721d2d4a6ef5ed154bba896a8215ec709e569785
Implement folding explicit load instructions into binary operations.  For a
testcase like this:

int %test(int* %P, int %A) {
        %Pv = load int* %P
        %B = add int %A, %Pv
        ret int %B
}

We now generate:
test:
        mov %ECX, DWORD PTR [%ESP + 4]
        mov %EAX, DWORD PTR [%ESP + 8]
        add %EAX, DWORD PTR [%ECX]
        ret

Instead of:
test:
        mov %EAX, DWORD PTR [%ESP + 4]
        mov %ECX, DWORD PTR [%ESP + 8]
        mov %EAX, DWORD PTR [%EAX]
        add %EAX, %ECX
        ret

... saving one instruction, and often a register.  Note that there are a lot
of other instructions that could use this, but they aren't handled.  I'm not
really interested in adding them, but mul/div and all of the FP instructions
could be supported as well if someone wanted to add them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12204 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/InstSelectSimple.cpp
lib/Target/X86/X86ISelSimple.cpp