llvm-6502/lib/Target
Chris Lattner 028adc422d Efficiently handle a long multiplication by a constant. For this testcase:
long %test(long %X) {
        %Y = mul long %X, 123
        ret long %Y
}

we used to generate:

test:
        sub %ESP, 12
        mov DWORD PTR [%ESP + 8], %ESI
        mov DWORD PTR [%ESP + 4], %EDI
        mov DWORD PTR [%ESP], %EBX
        mov %ECX, DWORD PTR [%ESP + 16]
        mov %ESI, DWORD PTR [%ESP + 20]
        mov %EDI, 123
        mov %EBX, 0
        mov %EAX, %ECX
        mul %EDI
        imul %ESI, %EDI
        add %ESI, %EDX
        imul %ECX, %EBX
        add %ESI, %ECX
        mov %EDX, %ESI
        mov %EBX, DWORD PTR [%ESP]
        mov %EDI, DWORD PTR [%ESP + 4]
        mov %ESI, DWORD PTR [%ESP + 8]
        add %ESP, 12
        ret

Now we emit:
test:
        mov %EAX, DWORD PTR [%ESP + 4]
        mov %ECX, DWORD PTR [%ESP + 8]
        mov %EDX, 123
        mul %EDX
        imul %ECX, %ECX, 123
        add %ECX, %EDX
        mov %EDX, %ECX
        ret

Which, incidently, is substantially nicer than what GCC manages:
T:
        sub     %esp, 8
        mov     %eax, 123
        mov     DWORD PTR [%esp], %ebx
        mov     %ebx, DWORD PTR [%esp+16]
        mov     DWORD PTR [%esp+4], %esi
        mov     %esi, DWORD PTR [%esp+12]
        imul    %ecx, %ebx, 123
        mov     %ebx, DWORD PTR [%esp]
        mul     %esi
        mov     %esi, DWORD PTR [%esp+4]
        add     %esp, 8
        lea     %edx, [%ecx+%edx]
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12692 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-06 04:29:36 +00:00
..
CBackend Add support for select constant expressions to the CBE, fixing SIOD 2004-04-01 05:28:26 +00:00
PowerPC fine grainify namespacification 2004-02-28 19:53:18 +00:00
Sparc Add support for many of the MRegisterInfo callbacks. 2004-04-02 20:53:37 +00:00
SparcV8 Add support for many of the MRegisterInfo callbacks. 2004-04-02 20:53:37 +00:00
SparcV9 In the perhaps not-to-distant future, we might support gep instructions that 2004-04-04 20:44:05 +00:00
X86 Efficiently handle a long multiplication by a constant. For this testcase: 2004-04-06 04:29:36 +00:00
Makefile Remove ghostly directory from the build 2004-03-11 04:42:41 +00:00
MRegisterInfo.cpp Put all LLVM code into the llvm namespace, as per bug 109. 2003-11-11 22:41:34 +00:00
Target.td Expose the "Other" value type to tablegen targets 2004-02-11 03:08:45 +00:00
TargetData.cpp Support getelementptr instructions which use uint's to index into structure 2004-04-05 01:30:19 +00:00
TargetFrameInfo.cpp Move implementations of functions here, which avoids #including <cstdlib> in the 2004-03-11 23:52:43 +00:00
TargetInstrInfo.cpp Adjust to change in TII ctor arguments 2004-02-29 06:31:44 +00:00
TargetMachine.cpp make -print-machineinstrs work for both SparcV9 and X86 2004-03-04 19:16:23 +00:00
TargetSchedInfo.cpp Eliminate the distinction between "real" and "unreal" instructions 2004-02-29 06:31:16 +00:00