Commit Graph

515 Commits

Author SHA1 Message Date
Andrew Lenharth
4563326472 simplify
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30535 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 15:37:57 +00:00
Chris Lattner
b8456460cb We went through all that trouble to compute whether it was safe to transform
this comparison, but never checked it.  Whoops, no wonder we miscompiled
177.mesa!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30511 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 04:44:59 +00:00
Evan Cheng
571c15e38a Back out Chris' last set of changes. This breaks 177.mesa and povray somehow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30505 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 01:39:40 +00:00
Evan Cheng
7df4ad9a7f 80 col.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30504 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 01:10:02 +00:00
Andrew Lenharth
16d7955eb0 If we have an add, do it in the pointer realm, not the int realm. This is critical in the linux kernel for pointer analysis correctness
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30496 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-19 18:24:51 +00:00
Chris Lattner
733f576d29 implement select.ll:test19-22
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30482 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-19 06:18:21 +00:00
Chris Lattner
6d7ca92bbf Fix an infinite loop building the CFE
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30465 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 18:27:05 +00:00
Chris Lattner
e695a3bd32 Implement InstCombine/cast.ll:test31. This speeds up 462.libquantum by 26%.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30456 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 05:27:43 +00:00
Chris Lattner
b7363791ed Implement Transforms/InstCombine/shift-sra.ll:test0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30450 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 04:31:40 +00:00
Chris Lattner
65b72baa59 Rewrite shift/and/compare sequences to promote better licm of the RHS.
Use isLogicalShift/isArithmeticShift to simplify code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30448 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 04:22:48 +00:00
Chris Lattner
f6bd07c7fe Fix Transforms/InstCombine/2006-09-15-CastToBool.ll and PR913
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30405 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-16 03:14:10 +00:00
Chris Lattner
63d3220dae Fix PR905 and InstCombine/2006-09-11-EmptyStructCrash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30266 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-11 21:43:16 +00:00
Chris Lattner
2a86f3b744 Implement Transforms/InstCombine/hoist_instr.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30234 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-09 22:02:56 +00:00
Chris Lattner
8e49e08f4b Turn div X, (Cond ? Y : 0) -> div X, Y
This implements select.ll::test18.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30230 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-09 20:26:32 +00:00
Chris Lattner
7f8897f22e eliminate RegisterOpt. It does the same thing as RegisterPass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29925 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-27 22:42:52 +00:00
Chris Lattner
a4f0b3a084 s|llvm/Support/Visibility.h|llvm/Support/Compiler.h|
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29911 91177308-0d34-0410-b5e6-96231b3b80d8
2006-08-27 12:54:02 +00:00
Chris Lattner
ed36b2f1c2 Silence a warning produced in assertions-disabled mode
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29108 91177308-0d34-0410-b5e6-96231b3b80d8
2006-07-11 18:31:26 +00:00
Owen Anderson
b64ab8769e Add a comment, and fix a typo that broke the build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29094 91177308-0d34-0410-b5e6-96231b3b80d8
2006-07-10 22:15:25 +00:00
Owen Anderson
7e05714a10 Don't indent the entire function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29093 91177308-0d34-0410-b5e6-96231b3b80d8
2006-07-10 22:03:18 +00:00
Chris Lattner
6423d4c64a Recognize 16-bit bswaps by relaxing overconstrained pattern.
This implements Transforms/InstCombine/bswap.ll:test[34].


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29087 91177308-0d34-0410-b5e6-96231b3b80d8
2006-07-10 20:25:24 +00:00
Owen Anderson
d1b78a12ef Make instcombine not remove Phi nodes when LCSSA is live.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29083 91177308-0d34-0410-b5e6-96231b3b80d8
2006-07-10 19:03:49 +00:00
Chris Lattner
f4b546110c Shrink libllvmgcc.dylib by another 23K
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28972 91177308-0d34-0410-b5e6-96231b3b80d8
2006-06-28 22:08:15 +00:00
Chris Lattner
d228018396 Fix Transforms/InstCombine/2006-06-28-infloop.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28961 91177308-0d34-0410-b5e6-96231b3b80d8
2006-06-28 17:34:50 +00:00
Andrew Lenharth
b8e604c29a Catch more function pointer casting problems
Remove the Function pointer cast in these calls, converting it to
a cast of argument.
%tmp60 = tail call int cast (int (ulong)* %str to int (int)*)( int 10 )
%tmp60 = tail call int cast (int (ulong)* %str to int (int)*)( uint %tmp51 )


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28953 91177308-0d34-0410-b5e6-96231b3b80d8
2006-06-28 01:01:52 +00:00
Chris Lattner
afe91a5f26 Implement Transforms/InstCombine/bswap.ll, turning common shift/and/or bswap
idioms into bswap intrinsics.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28803 91177308-0d34-0410-b5e6-96231b3b80d8
2006-06-15 19:07:26 +00:00
Chris Lattner
18a4af2ba6 Fix a bug in a recent patch. This fixes UnitTests/Vector/Altivec/casts.c on
PPC/altivec


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28698 91177308-0d34-0410-b5e6-96231b3b80d8
2006-06-06 22:26:02 +00:00
Chris Lattner
13d4ab4009 Swap the order of operands created here. For +&|^, the order doesn't matter,
but for sub, it really does!  Fix fixes a miscompilation of fibheap_cut in
llvmgcc4.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28600 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-31 21:14:00 +00:00
Chris Lattner
b4db97ffa7 Implement Transforms/InstCombine/store.ll:test2.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28503 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-26 19:19:20 +00:00
Chris Lattner
7b2e2792d6 Transform things like (splat(splat)) -> splat
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28490 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-26 00:29:06 +00:00
Chris Lattner
863bcff183 Introduce a helper function that simplifies interpretation of shuffle masks.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28489 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-25 23:48:38 +00:00
Chris Lattner
01575b7315 Turn (cast (shuffle (cast)) -> shuffle (cast) if it reduces the # casts in
the program.  This exposes more opportunities for the instcombiner, and implements
vec_shuffle.ll:test6


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28487 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-25 23:24:33 +00:00
Chris Lattner
73fa49d697 extract element from a shuffle vector can be trivially turned into an
extractelement from the SV's source.  This implement vec_shuffle.ll:test[45]


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28485 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-25 22:53:38 +00:00
Chris Lattner
01859e8853 Silence a bogus gcc warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28422 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-20 23:14:03 +00:00
Evan Cheng
3e246dd084 Backing out last check-in for now. It's causing an infinite loop gccas lencode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28284 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-14 06:46:03 +00:00
Chris Lattner
033aaaf451 Add/Sub/Mul are safe to promote here as well. Incrementing a single-bit
bitfield now gives this code:

_plus:
        lwz r2, 0(r3)
        rlwimi r2, r2, 0, 1, 31
        xoris r2, r2, 32768
        stw r2, 0(r3)
        blr

instead of this:

_plus:
        lwz r2, 0(r3)
        srwi r4, r2, 31
        slwi r4, r4, 31
        addis r4, r4, -32768
        rlwimi r2, r4, 0, 0, 0
        stw r2, 0(r3)
        blr

this can obviously still be improved.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28275 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-13 02:16:08 +00:00
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
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
Chris Lattner
f4f5a77fdc Two changes:
1. Implement InstCombine/deadcode.ll by not adding instructions in unreachable
   blocks (due to constants in conditional branches/switches) to the worklist.
   This causes them to be deleted before instcombine starts up, leading to
   better optimization.

2. In the prepass over instructions, do trivial constprop/dce as we go.  This
   has the effect of improving the effectiveness of #1.  In addition, it
   *significantly* speeds up instcombine on test cases with large amounts of
   constant folding code (for example, that produced by code specialization
   or partial evaluation).  In one example, it speeds up instcombine from
   0.0589s to 0.0224s with a release build (a 2.6x speedup).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28215 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-10 19:00:36 +00:00
Chris Lattner
33a6113995 Move some code around.
Make the "fold (and (cast A), (cast B)) -> (cast (and A, B))" transformation
only apply when both casts really will cause code to be generated.  If one or
both doesn't, then this xform doesn't remove a cast.

This fixes Transforms/InstCombine/2006-05-06-Infloop.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28141 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-06 09:00:16 +00:00
Chris Lattner
581a7ad7c9 Fix an infinite loop compiling oggenc last night.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28128 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-05 20:51:30 +00:00
Chris Lattner
6fc205fc44 Implement InstCombine/cast.ll:test29
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28126 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-05 06:39:07 +00:00
Chris Lattner
e3158308e0 Fix Transforms/InstCombine/2006-05-04-DemandedBitCrash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28101 91177308-0d34-0410-b5e6-96231b3b80d8
2006-05-04 17:33:35 +00:00
Chris Lattner
94046b4d10 Fix InstCombine/2006-04-28-ShiftShiftLongLong.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28019 91177308-0d34-0410-b5e6-96231b3b80d8
2006-04-28 22:21:41 +00:00
Chris Lattner
d929f06f4d Add support for inserting undef into a vector. This implements
Transforms/InstCombine/vec_insert_to_shuffle.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27997 91177308-0d34-0410-b5e6-96231b3b80d8
2006-04-27 21:14:21 +00:00
Andrew Lenharth
7a31b975fb Make code match cvs commit message :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27881 91177308-0d34-0410-b5e6-96231b3b80d8
2006-04-20 15:41:37 +00:00
Andrew Lenharth
8117f9a40e If we can convert the return pointer type into an integer that IntPtrType
can be converted to losslessly, we can continue the conversion to a direct call.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27880 91177308-0d34-0410-b5e6-96231b3b80d8
2006-04-20 14:56:47 +00:00
Chris Lattner
fd6bdf0b0f Turn x86 unaligned load/store intrinsics into aligned load/store instructions
if the pointer is known aligned.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27781 91177308-0d34-0410-b5e6-96231b3b80d8
2006-04-17 22:26:56 +00:00
Chris Lattner
7f6cc0ccb5 Fix a bug in the 'shuffle(undef,x,mask) -> shuffle(x, undef,mask')' xform
Make the insert/extract elt -> shuffle code more aggressive.

This fixes CodeGen/PowerPC/vec_shuffle.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27728 91177308-0d34-0410-b5e6-96231b3b80d8
2006-04-16 00:51:47 +00:00
Chris Lattner
706126dac1 Canonicalize shuffle(undef,x,mask) -> shuffle(x, undef,mask').
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27727 91177308-0d34-0410-b5e6-96231b3b80d8
2006-04-16 00:03:56 +00:00
Chris Lattner
efb47359ff significant cleanups to code that uses insert/extractelt heavily. This builds
maximal shuffles out of them where possible.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27717 91177308-0d34-0410-b5e6-96231b3b80d8
2006-04-15 01:39:45 +00:00