llvm-6502/lib/Target
Chris Lattner 2483f67914 Codegen signed mod by 2 or -2 more efficiently. Instead of generating:
t:
        mov %EDX, DWORD PTR [%ESP + 4]
        mov %ECX, 2
        mov %EAX, %EDX
        sar %EDX, 31
        idiv %ECX
        mov %EAX, %EDX
        ret

Generate:
t:
        mov %ECX, DWORD PTR [%ESP + 4]
***     mov %EAX, %ECX
        cdq
        and %ECX, 1
        xor %ECX, %EDX
        sub %ECX, %EDX
***     mov %EAX, %ECX
        ret

Note that the two marked moves are redundant, and should be eliminated by the
register allocator, but aren't.

Compare this to GCC, which generates:

t:
        mov     %eax, DWORD PTR [%esp+4]
        mov     %edx, %eax
        shr     %edx, 31
        lea     %ecx, [%edx+%eax]
        and     %ecx, -2
        sub     %eax, %ecx
        ret

or ICC 8.0, which generates:

t:
        movl      4(%esp), %ecx                                 #3.5
        movl      $-2147483647, %eax                            #3.25
        imull     %ecx                                          #3.25
        movl      %ecx, %eax                                    #3.25
        sarl      $31, %eax                                     #3.25
        addl      %ecx, %edx                                    #3.25
        subl      %edx, %eax                                    #3.25
        addl      %eax, %eax                                    #3.25
        negl      %eax                                          #3.25
        subl      %eax, %ecx                                    #3.25
        movl      %ecx, %eax                                    #3.25
        ret                                                     #3.25

We would be in great shape if not for the moves.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16763 91177308-0d34-0410-b5e6-96231b3b80d8
2004-10-06 05:01:07 +00:00
..
CBackend Really fix FreeBSD, which apparently doesn't tolerate the extern. 2004-10-06 04:21:52 +00:00
PowerPC Generate better code by being far less clever when it comes to the select instruction. Don't create overlapping register lifetimes 2004-09-29 05:00:31 +00:00
Skeleton Make sure to set the operand list 2004-09-21 17:30:54 +00:00
Sparc I think this will handle double args. 2004-09-30 19:44:32 +00:00
SparcV8 I think this will handle double args. 2004-09-30 19:44:32 +00:00
SparcV9 Make EmitMappingInfo into an "external location" option, so that it can be set 2004-09-30 20:20:01 +00:00
X86 Codegen signed mod by 2 or -2 more efficiently. Instead of generating: 2004-10-06 05:01:07 +00:00
Makefile Targets are independent of each other, so compile them in parallel 2004-09-15 01:34:25 +00:00
MRegisterInfo.cpp Add getAllocatableSet() function. 2004-08-26 22:21:04 +00:00
Target.td Add initial support for variants 2004-10-03 19:34:18 +00:00
TargetData.cpp Changes For Bug 352 2004-09-01 22:55:40 +00:00
TargetFrameInfo.cpp Remove dead methods 2004-08-12 18:37:15 +00:00
TargetInstrInfo.cpp ConstantTypeMustBeLoaded has been incorporated into SparcV9PreSelection, its 2004-07-27 21:43:38 +00:00
TargetMachine.cpp Changes For Bug 352 2004-09-01 22:55:40 +00:00
TargetMachineRegistry.cpp Implement TargetRegistrationListener 2004-07-11 06:03:21 +00:00
TargetSchedInfo.cpp Since we use alloca now make sure we include the proper headers for it. 2004-09-28 02:53:15 +00:00