summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Catch more function pointer casting problemsAndrew Lenharth2006-06-281-1/+9
| | | | | | | | | 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 ) llvm-svn: 28953
* Implement Transforms/InstCombine/bswap.ll, turning common shift/and/or bswapChris Lattner2006-06-151-1/+131
| | | | | | idioms into bswap intrinsics. llvm-svn: 28803
* Fix a bug in a recent patch. This fixes UnitTests/Vector/Altivec/casts.c onChris Lattner2006-06-061-1/+1
| | | | | | PPC/altivec llvm-svn: 28698
* Swap the order of operands created here. For +&|^, the order doesn't matter,Chris Lattner2006-05-311-2/+3
| | | | | | | but for sub, it really does! Fix fixes a miscompilation of fibheap_cut in llvmgcc4. llvm-svn: 28600
* Implement Transforms/InstCombine/store.ll:test2.Chris Lattner2006-05-261-1/+15
| | | | llvm-svn: 28503
* Transform things like (splat(splat)) -> splatChris Lattner2006-05-261-4/+50
| | | | llvm-svn: 28490
* Introduce a helper function that simplifies interpretation of shuffle masks.Chris Lattner2006-05-251-91/+64
| | | | | | No functionality change. llvm-svn: 28489
* Turn (cast (shuffle (cast)) -> shuffle (cast) if it reduces the # casts inChris Lattner2006-05-251-2/+31
| | | | | | | the program. This exposes more opportunities for the instcombiner, and implements vec_shuffle.ll:test6 llvm-svn: 28487
* extract element from a shuffle vector can be trivially turned into anChris Lattner2006-05-251-12/+41
| | | | | | extractelement from the SV's source. This implement vec_shuffle.ll:test[45] llvm-svn: 28485
* Silence a bogus gcc warningChris Lattner2006-05-201-1/+1
| | | | llvm-svn: 28422
* Backing out last check-in for now. It's causing an infinite loop gccas lencode.Evan Cheng2006-05-141-6/+0
| | | | llvm-svn: 28284
* Add/Sub/Mul are safe to promote here as well. Incrementing a single-bitChris Lattner2006-05-131-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 28275
* Implement simple promotion for cast elimination in instcombine. This isChris Lattner2006-05-131-0/+119
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 28273
* Refactor some code, making it simpler.Chris Lattner2006-05-111-31/+43
| | | | | | | | | | | 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. llvm-svn: 28224
* Two changes:Chris Lattner2006-05-101-7/+72
| | | | | | | | | | | | | | | | 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). llvm-svn: 28215
* Move some code around.Chris Lattner2006-05-061-124/+140
| | | | | | | | | | 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 llvm-svn: 28141
* Fix an infinite loop compiling oggenc last night.Chris Lattner2006-05-051-6/+9
| | | | llvm-svn: 28128
* Implement InstCombine/cast.ll:test29Chris Lattner2006-05-051-0/+40
| | | | llvm-svn: 28126
* Fix Transforms/InstCombine/2006-05-04-DemandedBitCrash.llChris Lattner2006-05-041-0/+4
| | | | llvm-svn: 28101
* Fix InstCombine/2006-04-28-ShiftShiftLongLong.llChris Lattner2006-04-281-1/+1
| | | | llvm-svn: 28019
* Add support for inserting undef into a vector. This implementsChris Lattner2006-04-271-3/+14
| | | | | | Transforms/InstCombine/vec_insert_to_shuffle.ll llvm-svn: 27997
* Make code match cvs commit message :)Andrew Lenharth2006-04-201-1/+1
| | | | llvm-svn: 27881
* If we can convert the return pointer type into an integer that IntPtrTypeAndrew Lenharth2006-04-201-2/+4
| | | | | | can be converted to losslessly, we can continue the conversion to a direct call. llvm-svn: 27880
* Turn x86 unaligned load/store intrinsics into aligned load/store instructionsChris Lattner2006-04-171-1/+16
| | | | | | if the pointer is known aligned. llvm-svn: 27781
* Fix a bug in the 'shuffle(undef,x,mask) -> shuffle(x, undef,mask')' xformChris Lattner2006-04-161-17/+84
| | | | | | | | Make the insert/extract elt -> shuffle code more aggressive. This fixes CodeGen/PowerPC/vec_shuffle.ll llvm-svn: 27728
* Canonicalize shuffle(undef,x,mask) -> shuffle(x, undef,mask').Chris Lattner2006-04-161-2/+22
| | | | llvm-svn: 27727
* significant cleanups to code that uses insert/extractelt heavily. This buildsChris Lattner2006-04-151-0/+126
| | | | | | maximal shuffles out of them where possible. llvm-svn: 27717
* Turn casts into getelementptr's when possible. This enables SROA to be moreChris Lattner2006-04-121-0/+23
| | | | | | | | aggressive in some cases where LLVMGCC 4 is inserting casts for no reason. This implements InstCombine/cast.ll:test27/28. llvm-svn: 27620
* Implement vec_shuffle.ll:test3Chris Lattner2006-04-101-2/+17
| | | | llvm-svn: 27573
* Implement InstCombine/vec_shuffle.ll:test[12]Chris Lattner2006-04-101-0/+62
| | | | llvm-svn: 27571
* Lower vperm(x,y, mask) -> shuffle(x,y,mask) if mask is constant. This allowsChris Lattner2006-04-061-8/+58
| | | | | | | | | | | | | | | | us to compile oh-so-realistic stuff like this: vec_vperm(A, B, (vector unsigned char){14}); to: vspltb v0, v0, 14 instead of: vspltisb v0, 14 vperm v0, v2, v1, v0 llvm-svn: 27452
* vector casts of casts are eliminable. Transform this:Chris Lattner2006-04-021-0/+4
| | | | | | | | | | | %tmp = cast <4 x uint> %tmp to <4 x int> ; <<4 x int>> [#uses=1] %tmp = cast <4 x int> %tmp to <4 x float> ; <<4 x float>> [#uses=1] into: %tmp = cast <4 x uint> %tmp to <4 x float> ; <<4 x float>> [#uses=1] llvm-svn: 27355
* Allow transforming this:Chris Lattner2006-04-021-2/+4
| | | | | | | | | | | | %tmp = cast <4 x uint>* %testData to <4 x int>* ; <<4 x int>*> [#uses=1] %tmp = load <4 x int>* %tmp ; <<4 x int>> [#uses=1] to this: %tmp = load <4 x uint>* %testData ; <<4 x uint>> [#uses=1] %tmp = cast <4 x uint> %tmp to <4 x int> ; <<4 x int>> [#uses=1] llvm-svn: 27353
* Turn altivec lvx/stvx intrinsics into loads and stores. This allows theChris Lattner2006-04-021-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | elimination of one load from this: int AreSecondAndThirdElementsBothNegative( vector float *in ) { #define QNaN 0x7FC00000 const vector unsigned int testData = (vector unsigned int)( QNaN, 0, 0, QNaN ); vector float test = vec_ld( 0, (float*) &testData ); return ! vec_any_ge( test, *in ); } Now generating: _AreSecondAndThirdElementsBothNegative: mfspr r2, 256 oris r4, r2, 49152 mtspr 256, r4 li r4, lo16(LCPI1_0) lis r5, ha16(LCPI1_0) addi r6, r1, -16 lvx v0, r5, r4 stvx v0, 0, r6 lvx v1, 0, r3 vcmpgefp. v0, v0, v1 mfcr r3, 2 rlwinm r3, r3, 27, 31, 31 xori r3, r3, 1 cntlzw r3, r3 srwi r3, r3, 5 mtspr 256, r2 blr llvm-svn: 27352
* Fix InstCombine/2006-04-01-InfLoop.llChris Lattner2006-04-011-1/+2
| | | | llvm-svn: 27330
* Fold A^(B&A) -> (B&A)^AChris Lattner2006-04-011-7/+46
| | | | | | | | Fold (B&A)^A == ~B & A This implements InstCombine/xor.ll:test2[56] llvm-svn: 27328
* If we can look through vector operations to find the scalar version of anChris Lattner2006-03-311-0/+40
| | | | | | extract_element'd value, do so. llvm-svn: 27323
* extractelement(undef,x) -> undefChris Lattner2006-03-311-6/+8
| | | | llvm-svn: 27300
* Fix Transforms/InstCombine/2006-03-30-ExtractElement.llChris Lattner2006-03-301-3/+7
| | | | llvm-svn: 27261
* Don't crash on packed logical opsChris Lattner2006-03-251-3/+6
| | | | llvm-svn: 27125
* Can't combine anymore - we don't have a chain through llvm.dbg intrinsics.Jim Laskey2006-03-231-10/+0
| | | | llvm-svn: 26992
* Teach the alignment handling code to look through constant expr casts and GEPsChris Lattner2006-03-071-4/+12
| | | | llvm-svn: 26580
* Teach instcombine to increase the alignment of memset/memcpy/memmove whenChris Lattner2006-03-061-3/+74
| | | | | | | | | | | | the pointer is known to come from either a global variable, alloca or malloc. This allows us to compile this: P = malloc(28); memset(P, 0, 28); into explicit stores on PPC instead of a memset call. llvm-svn: 26577
* Make vector narrowing more effective, implementingChris Lattner2006-03-051-22/+62
| | | | | | | Transforms/InstCombine/vec_narrow.ll. This add support for narrowing extract_element(insertelement) also. llvm-svn: 26538
* Canonicalize (X+C1)*C2 -> X*C2+C1*C2Chris Lattner2006-03-041-0/+13
| | | | | | This implements Transforms/InstCombine/add.ll:test31 llvm-svn: 26519
* Change this to work with renamed intrinsics.Chris Lattner2006-03-031-1/+7
| | | | llvm-svn: 26484
* Generalize the REM folding code to handle another case Nick LewyckyChris Lattner2006-03-021-13/+43
| | | | | | pointed out: realize the AND can provide factors and look through Casts. llvm-svn: 26469
* Fix a regression in a patch from a couple of days ago. This fixesChris Lattner2006-02-281-1/+3
| | | | | | Transforms/InstCombine/2006-02-28-Crash.ll llvm-svn: 26427
* Implement rem.ll:test[7-9] and PR712Chris Lattner2006-02-281-6/+22
| | | | llvm-svn: 26415
* Simplify some code now that the RHS of a rem can't be 0Chris Lattner2006-02-281-8/+6
| | | | llvm-svn: 26413
OpenPOWER on IntegriCloud