Commit Graph

25288 Commits

Author SHA1 Message Date
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
Chris Lattner
5250bae5ee New testcase for instcombine
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28272 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-13 02:00:07 +00:00
Chris Lattner
2144c25364 Remove some dead variables.
Fix a nasty bug in the memcmp optimizer where we used the wrong variable!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28269 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 23:35:26 +00:00
Chris Lattner
a87e9cd069 Remove dead stuff
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28268 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 23:32:01 +00:00
Chris Lattner
12d8f2bafe Fix build breakage :(
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28267 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 23:26:11 +00:00
Chris Lattner
98d0d7d6f0 More coverity fixes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28266 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 21:14:20 +00:00
Chris Lattner
03ea4c8326 Dead variable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28265 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 21:12:22 +00:00
Chris Lattner
b65e7256ed Remove dead var, fix bad override.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28264 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 21:09:57 +00:00
Reid Spencer
3e41da29fb Don't use old-style casts. This prevents compiler warnings when CommandLine.h
is used in projects that have stricter warning control than LLVM. This also
helps us find casts more easily if we ever need to.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28263 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 19:20:55 +00:00
Evan Cheng
3b6d56cab3 If the register allocator cannot find a register to spill, try the aliases. If
that still fails (because all the register spill weights are inf), just grab
one.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28262 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 19:07:46 +00:00
Evan Cheng
0bbac9ffd1 Remove dead code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28261 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 19:03:56 +00:00
Chris Lattner
095cc37e22 Fix accidentally committed patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28260 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 18:20:39 +00:00
Chris Lattner
666b042658 Actually override the right method. :)
Bug identified by coverity.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28259 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 18:19:25 +00:00
Chris Lattner
dd28ba2284 remove dead variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28258 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 18:17:25 +00:00
Chris Lattner
2b80e8d635 Fix iterator invalidation bug, identified by Coverity.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28257 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 18:13:11 +00:00
Chris Lattner
bbea1245a1 Fix a hypothetical memory leak, identified by Coverity. In practice, this
object is never deleted though.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28256 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 18:10:12 +00:00
Chris Lattner
b5d9319bc5 Remove dead vars
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28255 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 18:06:45 +00:00
Chris Lattner
f1343c1b79 remove dead vars
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28254 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 18:04:28 +00:00
Chris Lattner
c485e55c65 Remove dead variable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28253 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 18:02:04 +00:00
Chris Lattner
5eed34d208 Comment out dead variables
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28252 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 17:57:54 +00:00
Reid Spencer
ffb4d62720 When reading the symbol table, make sure to delete the ArchiveMember
created by reading the symbol table.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28251 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 17:56:20 +00:00
Chris Lattner
9dcb780e23 Remove dead var
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28250 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 17:50:35 +00:00
Chris Lattner
82db0696a1 Remove dead variable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28249 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 17:41:45 +00:00
Chris Lattner
b57b516f6d remove dead variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28248 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 17:33:59 +00:00
Chris Lattner
27aaa398ee Remove dead variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28247 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 17:31:21 +00:00
Chris Lattner
433698bbbc Avoid defining dead result
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28246 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 17:29:40 +00:00
Chris Lattner
b923b2e04b Remove dead return value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28245 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 17:28:36 +00:00
Chris Lattner
e41102bb61 Compile:
%tmp152 = setgt uint %tmp144, %tmp149           ; <bool> [#uses=1]
        %tmp159 = setlt uint %tmp144, %tmp149           ; <bool> [#uses=1]
        %bothcond2 = or bool %tmp152, %tmp159           ; <bool> [#uses=1]

To setne, not setune, which causes an assertion fault.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28244 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 17:03:46 +00:00
Chris Lattner
0949ed5412 Fix PowerPC/2006-05-12-rlwimi-crash.ll
Nate, please verify that if InsertMask is 0, rlwimi shouldn't be used.
This fixes the crash and causes no PPC testsuite regressions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28243 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 16:29:37 +00:00
Chris Lattner
83cdf40144 new testcase for a recent rlwimi crash.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28242 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 16:28:13 +00:00
Evan Cheng
9812f1ca97 Noop instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28241 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 07:47:00 +00:00
Evan Cheng
d9d4518a86 Unused instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28240 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 07:42:01 +00:00
Owen Anderson
2577c22131 Add a method to generate a string representation from a TargetData.
This continues the work on PR 761.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28239 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 07:01:44 +00:00
Owen Anderson
07000c6f01 Refactor a bunch of includes so that TargetMachine.h doesn't have to include
TargetData.h.  This should make recompiles a bit faster with my current
TargetData tinkering.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28238 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 06:33:49 +00:00
Owen Anderson
571a13f3e7 Fix some tabbing issues.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28237 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 06:06:55 +00:00
Evan Cheng
647c15e58e Backing out fix for PR770. Need to re-apply it after live range splitting is possible
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28236 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 06:06:34 +00:00
Evan Cheng
626da3d9ae Duh. That could take a long time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28235 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 06:05:18 +00:00
Owen Anderson
8f60c56a06 Add a new constructor to TargetData that builds a TargetData from its
string representation.

This is part of PR 761.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28234 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 05:49:47 +00:00
Chris Lattner
21a57dc751 Two simplifications for token factor nodes: simplify tf(x,x) -> x.
simplify tf(x,y,y,z) -> tf(x,y,z).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28233 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 05:01:37 +00:00
Evan Cheng
29225b1d32 New scheduling test case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28232 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 01:59:17 +00:00
Evan Cheng
13d41b9d72 Add capability to scheduler to commute nodes for profit.
If a two-address code whose first operand has uses below, it should be commuted
when possible.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28230 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 01:58:24 +00:00
Evan Cheng
31ff1ff348 Typo! How did we commute nodes before?!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28229 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 01:46:26 +00:00
Chris Lattner
a5f0419b4e For extra sanity checking, fill free'd memory with garbage so we know that
people aren't reusing machine code buffers at all.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28228 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-12 00:03:12 +00:00
Chris Lattner
9f3d1ba9ad Fix some bugs in the freelist manipulation code.
Finally, implement ExecutionEngine::freeMachineCodeForFunction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28227 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-11 23:56:57 +00:00
Evan Cheng
e165a78551 Refactor scheduler code. Move register-reduction list scheduler to a
separate file. Added an initial implementation of top-down register pressure
reduction list scheduler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28226 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-11 23:55:42 +00:00
Chris Lattner
e993cc27ad Significantly revamp allocation of machine code to use free lists, real
allocation policies and much more.  All this complexity, and we have no
functionality change, woo! :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28225 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-11 23:08:08 +00:00
Chris Lattner
8c8c66a8cd Refactor some code, making it simpler.
When doing the initial pass of constant folding, if we get a constantexpr,
simplify the constant expr like we would do if the constant is folded in the
normal loop.

This fixes the missed-optimization regression in
Transforms/InstCombine/getelementptr.ll last night.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28224 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-11 17:11:52 +00:00
Evan Cheng
f4df680ad4 Add MOV16_rm / MOV32_rm and MOV16_mr / MOV32_mr to isLoadFromStackSlot and isStoreToStackSlot
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28223 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-11 07:33:49 +00:00
Evan Cheng
c3580cace2 Also add super- register class info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28222 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-11 07:31:44 +00:00
Evan Cheng
2ca0efd71a Also add super- register classes info.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28221 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-11 07:30:26 +00:00