llvm-6502/lib
Chris Lattner 70074e00a2 Implement simple promotion for cast elimination in instcombine. This is
currently very limited, but can be extended in the future.  For example,
we now compile:

uint %test30(uint %c1) {
        %c2 = cast uint %c1 to ubyte
        %c3 = xor ubyte %c2, 1
        %c4 = cast ubyte %c3 to uint
        ret uint %c4
}

to:

_xor:
        movzbl 4(%esp), %eax
        xorl $1, %eax
        ret

instead of:

_xor:
        movb $1, %al
        xorb 4(%esp), %al
        movzbl %al, %eax
        ret

More impressively, we now compile:

struct B { unsigned bit : 1; };
void xor(struct B *b) { b->bit = b->bit ^ 1; }

To (X86/PPC):

_xor:
        movl 4(%esp), %eax
        xorl $-2147483648, (%eax)
        ret
_xor:
        lwz r2, 0(r3)
        xoris r2, r2, 32768
        stw r2, 0(r3)
        blr

instead of (X86/PPC):

_xor:
        movl 4(%esp), %eax
        movl (%eax), %ecx
        movl %ecx, %edx
        shrl $31, %edx
        # TRUNCATE movb %dl, %dl
        xorb $1, %dl
        movzbl %dl, %edx
        andl $2147483647, %ecx
        shll $31, %edx
        orl %ecx, %edx
        movl %edx, (%eax)
        ret

_xor:
        lwz r2, 0(r3)
        srwi r4, r2, 31
        xori r4, r4, 1
        rlwimi r2, r4, 31, 0, 0
        stw r2, 0(r3)
        blr

This implements InstCombine/cast.ll:test30.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28273 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-13 02:06:03 +00:00
..
Analysis Remove dead variable 2006-05-12 17:41:45 +00:00
Archive When reading the symbol table, make sure to delete the ArchiveMember 2006-05-12 17:56:20 +00:00
AsmParser Make sure CVS versions of yacc and lex files get distributed. 2006-04-12 20:57:05 +00:00
Bytecode When reading the symbol table, make sure to delete the ArchiveMember 2006-05-12 17:56:20 +00:00
CodeGen If the register allocator cannot find a register to spill, try the aliases. If 2006-05-12 19:07:46 +00:00
Debugger Add the README files to the distribution. 2006-04-13 06:39:24 +00:00
ExecutionEngine Fix a hypothetical memory leak, identified by Coverity. In practice, this 2006-05-12 18:10:12 +00:00
Linker Add shufflevector support 2006-04-08 01:19:47 +00:00
Support Fix PR743: emit -help output of a tool to cout, not cerr. 2006-04-28 05:36:25 +00:00
System Fix accidentally committed patch. 2006-05-12 18:20:39 +00:00
Target Fix build breakage :( 2006-05-12 23:26:11 +00:00
Transforms Implement simple promotion for cast elimination in instcombine. This is 2006-05-13 02:06:03 +00:00
VMCore Add an assertion for a common error 2006-05-10 04:32:43 +00:00
Makefile