summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* add one more bitfield optimization, allowing clang to generateChris Lattner2010-01-111-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | good code on PR4216: _test_bitfield: ## @test_bitfield orl $32962, %edi movl $4294941946, %eax andq %rdi, %rax ret instead of: _test_bitfield: movl $4294941696, %ecx movl %edi, %eax orl $194, %edi orl $32768, %eax andq $250, %rdi andq %rax, %rcx movq %rdi, %rax orq %rcx, %rax ret Evan is looking into the remaining andq+imm -> andl optimization. llvm-svn: 93147
* Extend CanEvaluateZExtd to handle and/or/xor more aggressively in theChris Lattner2010-01-111-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BitsToClear case. This allows it to promote expressions which have an and/or/xor after the lshr, promoting cases like test2 (from PR4216) and test3 (random extample extracted from a spec benchmark). clang now compiles the code in PR4216 into: _test_bitfield: ## @test_bitfield movl %edi, %eax orl $194, %eax movl $4294902010, %ecx andq %rax, %rcx orl $32768, %edi andq $39936, %rdi movq %rdi, %rax orq %rcx, %rax ret instead of: _test_bitfield: ## @test_bitfield movl %edi, %eax orl $194, %eax movl $4294902010, %ecx andq %rax, %rcx shrl $8, %edi orl $128, %edi shlq $8, %rdi andq $39936, %rdi movq %rdi, %rax orq %rcx, %rax ret which is still not great, but is progress. llvm-svn: 93145
* Remove the dead TD argument to CanEvaluateZExtd, and add aChris Lattner2010-01-111-14/+57
| | | | | | | | | new BitsToClear result which allows us to start promoting expressions that end with a lshr-by-constant. This is conservatively correct and better than what we had before (see testcases) but still needs to be extended further. llvm-svn: 93144
* improve comments, remove dead TD argument to CanEvaluateSExtd.Chris Lattner2010-01-111-11/+12
| | | | llvm-svn: 93143
* teach sext optimization to handle truncs from types that are notChris Lattner2010-01-101-3/+4
| | | | | | the dest of the sext. llvm-svn: 93128
* teach zext optimization how to deal with truncs that don't come fromChris Lattner2010-01-101-12/+12
| | | | | | | | | | | | | | | | | the zext dest type. This allows us to handle test52/53 in cast.ll, and allows llvm-gcc to generate much better code for PR4216 in -m64 mode: _test_bitfield: ## @test_bitfield orl $32962, %edi movl %edi, %eax andl $-25350, %eax ret This also fixes a bug handling vector extends, ensuring that the mask produced is a vector constant, not an integer constant. llvm-svn: 93127
* simplify CanEvaluateSExtd to return a bool now that we have aChris Lattner2010-01-101-63/+22
| | | | | | simpler profitability predicate. llvm-svn: 93111
* the NumCastsRemoved argument to CanEvaluateSExtd is dead, remove it.Chris Lattner2010-01-101-26/+13
| | | | llvm-svn: 93110
* now that the cost model has changed, we can always consider Chris Lattner2010-01-101-25/+16
| | | | | | | | elimination of a sign extend to be a win, which simplifies the client of CanEvaluateSExtd, and allows us to eliminate more casts (examples taken from real code). llvm-svn: 93109
* change the preferred canonical form for a sign extension to beChris Lattner2010-01-102-23/+8
| | | | | | | | lshr+ashr instead of trunc+sext. We want to avoid type conversions whenever possible, it is easier to codegen expressions without truncates and extensions. llvm-svn: 93107
* fix indentation of switch statements, no functionality change.Chris Lattner2010-01-101-79/+79
| | | | llvm-svn: 93106
* fix pasto that broke bootstrap.Chris Lattner2010-01-101-1/+1
| | | | llvm-svn: 93105
* simplify CanEvaluateZExtd now that we don't care about the number of Chris Lattner2010-01-101-89/+23
| | | | | | | bits known clear in the result and don't care about the # casts eliminated. TD is also dead but keeping it for now. llvm-svn: 93098
* two changes: Chris Lattner2010-01-101-25/+27
| | | | | | | | | | | 1) don't try to optimize a sext or zext that is only used by a trunc, let the trunc get optimized first. This avoids some pointless effort in some common cases since instcombine scans down a block in the first pass. 2) Change the cost model for zext elimination to consider an 'and' cheaper than a zext. This allows us to do it more aggressively, and for the next patch to simplify the code quite a bit. llvm-svn: 93097
* enhance CanEvaluateZExtd to handle shift left and sext, allowingChris Lattner2010-01-101-3/+17
| | | | | | more expressions to be promoted and casts eliminated. llvm-svn: 93096
* remove an xform subsumed by EvaluateInDifferentType.Chris Lattner2010-01-101-27/+0
| | | | llvm-svn: 93095
* Fix nondeterministic behavior.Julien Lerouge2010-01-101-9/+3
| | | | llvm-svn: 93093
* clean up this xform by using m_Trunc.Chris Lattner2010-01-101-12/+9
| | | | llvm-svn: 93092
* inline and remove the rest of commonIntCastTransforms.Chris Lattner2010-01-102-18/+18
| | | | llvm-svn: 93091
* Inline the expression type promotion/demotion stuff out ofChris Lattner2010-01-101-417/+417
| | | | | | | | | commonIntCastTransforms into the callers, eliminating a switch, and allowing the static predicate methods to be moved down to live next to the corresponding function. No functionality change. llvm-svn: 93089
* only factor from expressions whose uses are empty and whoseChris Lattner2010-01-091-0/+5
| | | | | | base is the right expression type. This fixes PR5981. llvm-svn: 93045
* Fix nondeterministic behavior.Julien Lerouge2010-01-091-6/+7
| | | | llvm-svn: 93038
* Remove unnecessary dyn_cast and add a comment. Part of a WIP.Eric Christopher2010-01-081-4/+4
| | | | llvm-svn: 93026
* mplement a theoretical fixme.Chris Lattner2010-01-081-3/+7
| | | | llvm-svn: 93024
* rename CanEvaluateInDifferentType -> CanEvaluateTruncated and Chris Lattner2010-01-081-71/+28
| | | | | | simplify it now that it is only used for truncates. llvm-svn: 93021
* teach instcombine to delete sign extending shift pairs (sra(shl X, C), C) whenChris Lattner2010-01-081-4/+15
| | | | | | the input is already sign extended. llvm-svn: 93019
* Suppress an unused variable warning when assertions are off;Duncan Sands2010-01-081-2/+3
| | | | | | remove some trailing whitespace while there. llvm-svn: 93008
* tidy up some stuff duncan pointed out.Chris Lattner2010-01-081-2/+3
| | | | llvm-svn: 93007
* teach ComputeNumSignBits to look through PHI nodes.Chris Lattner2010-01-071-3/+0
| | | | llvm-svn: 92964
* Enhance instcombine to reason more strongly about promoting computationChris Lattner2010-01-071-51/+144
| | | | | | | that feeds into a zext, similar to the patch I did yesterday for sext. There is a lot of room for extension beyond this patch. llvm-svn: 92962
* Use a do-while loop instead of while + boolean.Benjamin Kramer2010-01-071-6/+4
| | | | llvm-svn: 92912
* Be less stingy as to how many selects and phi nodes weDuncan Sands2010-01-071-2/+2
| | | | | | are prepared to look through. llvm-svn: 92898
* handle ConstantVector while I'm in here.Chris Lattner2010-01-071-0/+3
| | | | llvm-svn: 92892
* fix a globalopt crash on 'bullet' (handling evaluation of a storeChris Lattner2010-01-071-16/+20
| | | | | | | | | | to an element of a vector in a static ctor) which occurs with an unrelated patch I'm testing. Annoyingly, EvaluateStoreInto basically does exactly the same stuff as InsertElement constant folding, but it now handles vectors, and you can't insertelement into a vector. It would be 'really nice' if GEP into a vector were not legal. llvm-svn: 92889
* Move the object size intrinsic optimization to inst-combine and makeEric Christopher2010-01-062-24/+12
| | | | | | it work for any integer size return type. llvm-svn: 92853
* Fix a README item: have functionattrs look through selects andDuncan Sands2010-01-061-10/+41
| | | | | | | | | phi nodes when deciding which pointers point to local memory. I actually checked long ago how useful this is, and it isn't very: it hardly ever fires in the testsuite, but since Chris wants it here it is! llvm-svn: 92836
* Formatting.Mikhail Glushenkov2010-01-061-2/+2
| | | | llvm-svn: 92831
* Partially address a README by having functionattrs consider calls toDuncan Sands2010-01-061-0/+15
| | | | | | | | | | memcpy, memset and other intrinsics that only access their arguments to be readnone if the intrinsic's arguments all point to local memory. This improves the testcase in the README to readonly, but it could in theory be made readnone, however this would involve more sophisticated analysis that looks through the memcpy. llvm-svn: 92829
* tweaks suggested by DuncanChris Lattner2010-01-061-7/+7
| | | | llvm-svn: 92824
* Teach instcombine's sext elimination logic to be more aggressive.Chris Lattner2010-01-061-18/+168
| | | | | | | | | | | | | | Previously, instcombine would only promote an expression tree to the larger type if doing so eliminated two casts. This is because a need to manually do the sign extend after the promoted expression tree with two shifts. Now, we keep track of whether the result of the computation is going to be properly sign extended already. If so, we can unconditionally promote the expression, which allows us to zap more sext's. This implements rdar://6598839 (aka gcc pr38751) llvm-svn: 92815
* simplify this code.Chris Lattner2010-01-051-109/+66
| | | | llvm-svn: 92800
* make this a static function instead of a method.Chris Lattner2010-01-052-6/+5
| | | | llvm-svn: 92795
* more rearrangement and cleanup, fix my test failure.Chris Lattner2010-01-051-118/+104
| | | | llvm-svn: 92792
* cleanupChris Lattner2010-01-051-18/+15
| | | | llvm-svn: 92790
* remove two trunc xforms that are subsumed by EvaluateInDifferentType.Chris Lattner2010-01-051-36/+0
| | | | | | | The only difference is that EvaluateInDifferentType checks to ensure they are profitable before doing them :) llvm-svn: 92788
* just remove this xform which is subsumed by others.Chris Lattner2010-01-051-26/+1
| | | | llvm-svn: 92775
* move a trunc-specific transform out of commonIntCastTransforms into visitTrunc.Chris Lattner2010-01-051-32/+34
| | | | llvm-svn: 92773
* Move remaining stuff to the isInteger predicate.Benjamin Kramer2010-01-055-17/+13
| | | | llvm-svn: 92771
* move a zext specific xform out of commonIntCastTransforms into visitZExt and ↵Chris Lattner2010-01-051-10/+9
| | | | | | modernize it. llvm-svn: 92770
* move a trunc-specific xform out of commonIntCastTransforms into visitTruncChris Lattner2010-01-051-16/+25
| | | | llvm-svn: 92768
OpenPOWER on IntegriCloud