llvm-6502/lib
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
..
Analysis Sparc don't got not "sqrtl", bum bum bum 2004-04-05 19:05:15 +00:00
Archive Use the true, decoded name of the archive member in getObjectType. 2004-03-31 19:51:00 +00:00
AsmParser Support getelementptr instructions which use uint's to index into structure 2004-04-05 01:30:04 +00:00
Bytecode Implement support for a new LLVM 1.3 bytecode format, which uses uint's 2004-04-05 01:27:26 +00:00
CodeGen MBB::remove should not modify the iterator passed in 2004-03-31 21:59:59 +00:00
Debugger "fix" a nasty race condition 2004-01-14 21:18:03 +00:00
ExecutionEngine Adjust to new interface 2004-04-04 19:47:06 +00:00
Linker Fix linking of constant expr casts due to type resolution changes. With 2004-03-31 02:58:28 +00:00
Support lli no longer takes the -quiet option! 2004-04-05 20:28:41 +00:00
Target Efficiently handle a long multiplication by a constant. For this testcase: 2004-04-06 04:29:36 +00:00
Transforms Fix a bug in yesterdays checkins which broke siod. siod is a great testcase! :) 2004-04-05 16:02:41 +00:00
VMCore Do not mangle intrinsics in any way! 2004-04-05 20:17:53 +00:00
Makefile CBackend is no longer here 2004-02-13 23:29:37 +00:00