llvm-6502/lib
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
..
Analysis 'Pass' should now not be derived from by clients. Instead, they should derive 2004-09-20 04:48:05 +00:00
Archive Changes For Bug 352 2004-09-01 22:55:40 +00:00
AsmParser Okay, the list of link-time passes wasn't such a hot idea. Its prone to 2004-09-14 05:43:23 +00:00
Bytecode Fix doxygen comment 2004-09-28 16:57:46 +00:00
CodeGen Do not repeat the map lookup 2004-10-01 23:16:43 +00:00
Debugger Changes For Bug 352 2004-09-01 22:55:40 +00:00
ExecutionEngine Convert code to compile with vc7.1. 2004-09-15 17:06:42 +00:00
Linker Make sure the const bit gets inherited correctly when linking declarations 2004-10-05 02:28:11 +00:00
Support Excise the ill-advised RLCOMP compression algorithm and simply leave the 2004-10-04 17:45:44 +00:00
System Must include sys/stat.h before declaring a 'struct stat' 2004-10-05 18:46:59 +00:00
Target Codegen signed mod by 2 or -2 more efficiently. Instead of generating: 2004-10-06 05:01:07 +00:00
Transforms Reduce code growth implied by the tail duplication pass by not duplicating 2004-10-06 03:27:37 +00:00
VMCore Make sure the const bit gets inherited correctly when linking declarations 2004-10-05 02:28:11 +00:00
Makefile Wrap long line 2004-09-15 01:34:42 +00:00