summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* InstructionSimplify should be able to simplify A+B==B+A to 'true'Duncan Sands2012-11-161-0/+9
| | | | | | but wasn't due to the same logic bug that caused PR14361. llvm-svn: 168186
* Fix PR14361: wrong simplification of A+B==B+A. You may think that the old logicDuncan Sands2012-11-161-0/+18
| | | | | | | | | replaced by this patch is equivalent to the new logic, but you'd be wrong, and that's exactly where the bug was. There's a similar bug in instsimplify which manifests itself as instsimplify failing to simplify this, rather than doing it wrong, see next commit. llvm-svn: 168181
* Constant::IsThreadDependent(): Use dyn_cast<Constant> instead of castHans Wennborg2012-11-161-0/+20
| | | | | | | | | | | It turns out that the operands of a Constant are not always themselves Constant. For example, one of the operands of BlockAddress is BasicBlock, which is not a Constant. This should fix the dragonegg-x86_64-linux-gcc-4.6-test build which broke in r168037. llvm-svn: 168147
* Make GlobalOpt be conservative with TLS variables (PR14309)Hans Wennborg2012-11-151-0/+53
| | | | | | | | | | | | | | For global variables that get the same value stored into them everywhere, GlobalOpt will replace them with a constant. The problem is that a thread-local GlobalVariable looks like one value (the address of the TLS var), but is different between threads. This patch introduces Constant::isThreadDependent() which returns true for thread-local variables and constants which depend on them (e.g. a GEP into a thread-local array), and teaches GlobalOpt not to track such values. llvm-svn: 168037
* Fix a crash observed by Shuxin Yang. The issue here is that LinearizeExprTree,Duncan Sands2012-11-151-0/+9
| | | | | | | | | | | | | | the utility for extracting a chain of operations from the IR, thought that it might as well combine any constants it came across (rather than just returning them along with everything else). On the other hand, the factorization code would like to see the individual constants (this is quite reasonable: it is much easier to pull a factor of 3 out of 2*3 than it is to pull it out of 6; you may think 6/3 isn't so hard, but due to overflow it's not as easy to undo multiplications of constants as it may at first appear). This patch therefore makes LinearizeExprTree stupider: it now leaves optimizing to the optimization part of reassociate, and sticks to just analysing the IR. llvm-svn: 168035
* Remove DOS line endings.Jakub Staszak2012-11-141-21/+21
| | | | llvm-svn: 167968
* Fix the instcombine GEP index widening transform to work correctly for vectorDuncan Sands2012-11-131-0/+5
| | | | | | getelementptrs. llvm-svn: 167829
* Relax the restrictions on vector of pointer types, and vector getelementptr.Duncan Sands2012-11-131-2/+2
| | | | | | | | | | | | | | | Previously in a vector of pointers, the pointer couldn't be any pointer type, it had to be a pointer to an integer or floating point type. This is a hassle for dragonegg because the GCC vectorizer happily produces vectors of pointers where the pointer is a pointer to a struct or whatever. Vector getelementptr was restricted to just one index, but now that vectors of pointers can have any pointer type it is more natural to allow arbitrary vector getelementptrs. There is however the issue of struct GEPs, where if each lane chose different struct fields then from that point on each lane will be working down into unrelated types. This seems like too much pain for too little gain, so when you have a vector struct index all the elements are required to be the same. llvm-svn: 167828
* Figure out <size> argument of llvm.lifetime intrinsics at the moment they ↵Alexey Samsonov2012-11-132-11/+56
| | | | | | are created (during function inlining) llvm-svn: 167821
* instcombine: Migrate math library call simplificationsMeador Inge2012-11-1313-338/+525
| | | | | | | | | | | | | | | | | This patch migrates the math library call simplifications from the simplify-libcalls pass into the instcombine library call simplifier. I have typically migrated just one simplifier at a time, but the math simplifiers are interdependent because: 1. CosOpt, PowOpt, and Exp2Opt all depend on UnaryDoubleFPOpt. 2. CosOpt, PowOpt, Exp2Opt, and UnaryDoubleFPOpt all depend on the option -enable-double-float-shrink. These two factors made migrating each of these simplifiers individually more of a pain than it would be worth. So, I migrated them all together. llvm-svn: 167815
* BBVectorize: Don't vectorize vector-manipulation chainsHal Finkel2012-11-131-0/+170
| | | | | | | | Don't choose a vectorization plan containing only shuffles and vector inserts/extracts. Due to inperfections in the cost model, these can lead to infinite recusion. llvm-svn: 167811
* revert r167740Shuxin Yang2012-11-132-16/+3
| | | | llvm-svn: 167787
* BBVectorize: Only some insert element operand pairs are free.Hal Finkel2012-11-121-0/+85
| | | | | | | | This fixes another infinite recursion case when using target costs. We can only replace insert element input chains that are pure (end with inserting into an undef). llvm-svn: 167784
* BBVectorize: Use a more sophisticated check for input costHal Finkel2012-11-121-0/+54
| | | | | | | | | The old checking code, which assumed that input shuffles and insert-elements could always be folded (and thus were free) is too simple. This can only happen in special circumstances. Using the simple check caused infinite recursion. llvm-svn: 167750
* BBVectorize: Check the types of compare instructionsHal Finkel2012-11-121-0/+16
| | | | | | | The pass would previously assert when trying to compute the cost of compare instructions with illegal vector types (like struct pointers). llvm-svn: 167743
* This change is to fix rdar://12571717 which is about assertion in ↵Shuxin Yang2012-11-122-3/+16
| | | | | | | | | | | | | | | | | | Reassociate pass. The assertion is trigged when the Reassociater tries to transform expression ... + 2 * n * 3 + 2 * m + ... into: ... + 2 * (n*3 + m). In the process of the transformation, a helper routine folds the constant 2*3 into 6, confusing optimizer which is trying the to eliminate the common factor 2, and cannot find 2 any more. Review is pending. But I'd like commit first in order to help those who are waiting for this fix. llvm-svn: 167740
* BBVectorize: Check the input types of shuffles for legalityHal Finkel2012-11-121-0/+25
| | | | | | | | | | This fixes a bug where shuffles were being fused such that the resulting input types were not legal on the target. This would occur only when both inputs and dependencies were also foldable operations (such as other shuffles) and there were other connected pairs in the same block. llvm-svn: 167731
* Normalize memcmp constant folding results.Meador Inge2012-11-121-2/+2
| | | | | | | | | | | | | | | | | | | The library call simplifier folds memcmp calls with all constant arguments to a constant. For example: memcmp("foo", "foo", 3) -> 0 memcmp("hel", "foo", 3) -> 1 memcmp("foo", "hel", 3) -> -1 The folding is implemented in terms of the system memcmp that LLVM gets linked with. It currently just blindly uses the value returned from the system memcmp as the folded constant. This patch normalizes the values returned from the system memcmp to (-1, 0, 1) so that we get consistent results across multiple platforms. The test cases were adjusted accordingly. llvm-svn: 167726
* Remove hard-coded constant in Transforms/InstCombine/memcmp-1.llMeador Inge2012-11-111-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | Transforms/InstCombine/memcmp-1.ll has a test case that looks like: @foo = constant [4 x i8] c"foo\00" @hel = constant [4 x i8] c"hel\00" ... %mem1 = getelementptr [4 x i8]* @hel, i32 0, i32 0 %mem2 = getelementptr [4 x i8]* @foo, i32 0, i32 0 %ret = call i32 @memcmp(i8* %mem1, i8* %mem2, i32 3) ret i32 %ret ; CHECK: ret i32 2 The folded return value (2 above) is computed using the system memcmp that the compiler is linked with. This can return different values on different systems. The test was originally written on an OS X 10.7.5 x86-64 box and passed. However, it failed on one of the x86-64 FreeBSD buildbots because the system memcpy on that machine returned a different value (1 instead of 2). I fixed the test by checking the folding constants with regexes. llvm-svn: 167691
* instcombine: Migrate memset optimizationsMeador Inge2012-11-114-24/+34
| | | | | | | This patch migrates the memset optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167689
* instcombine: Migrate memmove optimizationsMeador Inge2012-11-113-12/+34
| | | | | | | This patch migrates the memmove optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167687
* instcombine: Migrate memcpy optimizationsMeador Inge2012-11-112-0/+34
| | | | | | | This patch migrates the memcpy optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167686
* instcombine: Migrate memcmp optimizationsMeador Inge2012-11-114-39/+86
| | | | | | | This patch migrates the memcmp optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167683
* instcombine: Migrate strstr optimizationsMeador Inge2012-11-113-60/+83
| | | | | | | This patch migrates the strstr optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167682
* instcombine: Migrate strcspn optimizationsMeador Inge2012-11-104-25/+87
| | | | | | | This patch migrates the strcspn optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167675
* instcombine: Query target library information to gate libcall simplificationsMeador Inge2012-11-101-0/+227
| | | | | | | | | Several of the simplifiers migrated from the simplify-libcalls pass to the instcombine pass were not correctly checking the target library information to gate the simplifications. This patch ensures that the check is made. llvm-svn: 167660
* Add support for memory runtime check. When we can, we calculate array bounds.Nadav Rotem2012-11-091-0/+36
| | | | | | | If the arrays are found to be disjoint then we run the vectorized version of the loop. If they are not, we run the scalar code. llvm-svn: 167608
* llvm/ConstantFolding.cpp: Make ReadDataFromGlobal() and ↵NAKAMURA Takumi2012-11-084-43/+112
| | | | | | FoldReinterpretLoadFromConstPtr() Big-endian-aware. llvm-svn: 167595
* instcombine: Migrate strspn optimizationsMeador Inge2012-11-082-16/+56
| | | | | | | This patch migrates the strspn optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167568
* Only do switch-to-lookup table transformation when TargetTransformInfoHans Wennborg2012-11-073-4/+9
| | | | | | is available. llvm-svn: 167552
* Fix bad test IR in switch_to_lookup_table.llHans Wennborg2012-11-071-1/+1
| | | | llvm-svn: 167543
* Cost Model: add tables for some avx type-conversion hacks.Nadav Rotem2012-11-061-1/+1
| | | | llvm-svn: 167480
* Code Model: Improve the accuracy of the zext/sext/trunc vector cost estimation.Nadav Rotem2012-11-051-2/+2
| | | | llvm-svn: 167412
* Implement the cost of abnormal x86 instruction lowering as a table.Nadav Rotem2012-11-051-1/+1
| | | | llvm-svn: 167395
* Generalize the transform that boosts GEP indices to the size of a pointer toDuncan Sands2012-11-031-0/+11
| | | | | | also do it for vectors of pointers. llvm-svn: 167354
* Add a testcase to loop-idiom to cover PR14241 when we start handlingChandler Carruth2012-11-021-0/+33
| | | | | | strided loops again. llvm-svn: 167287
* Revert the switch of loop-idiom to use the new dependence analysis.Chandler Carruth2012-11-025-218/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The new analysis is not yet ready for prime time. It has a *critical* flawed assumption, and some troubling shortages of testing. Until it's been hammered into better shape, let's stick with the working code. This should be easy to revert itself when the analysis is ready. Fixes PR14241, a miscompile of any memcpy-able loop which uses a pointer as the induction mechanism. If you have been seeing miscompiles in this revision range, you really want to test with this backed out. The results of this miscompile are a bit subtle as they can lead to downstream passes concluding things are impossible which are in fact possible. Thanks to David Blaikie for the majority of the reduction of this miscompile. I'll be checking in the test case in a non-revert commit. Revesions reverted here: r167045: LoopIdiom: Fix a serious missed optimization: we only turned top-level loops into memmove. r166877: LoopIdiom: Add checks to avoid turning memmove into an infinite loop. r166875: LoopIdiom: Recognize memmove loops. r166874: LoopIdiom: Replace custom dependence analysis with DependenceAnalysis. llvm-svn: 167286
* BBVectorize: Commit the rest of the test-case change.Hal Finkel2012-11-011-41/+1
| | | | llvm-svn: 167257
* BBVectorize: Use target costs for incoming and outgoing values instead of ↵Hal Finkel2012-11-012-11/+99
| | | | | | | | | | | the depth heuristic. When target cost information is available, compute explicit costs of inserting and extracting values from vectors. At this point, all costs are estimated using the target information, and the chain-depth heuristic is not needed. As a result, it is now, by default, disabled when using target costs. llvm-svn: 167256
* Add a test case for PR14233.Chandler Carruth2012-11-011-0/+53
| | | | llvm-svn: 167224
* Revert the series of commits starting with r166578 which introduced theChandler Carruth2012-11-011-235/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | getIntPtrType support for multiple address spaces via a pointer type, and also introduced a crasher bug in the constant folder reported in PR14233. These commits also contained several problems that should really be addressed before they are re-committed. I have avoided reverting various cleanups to the DataLayout APIs that are reasonable to have moving forward in order to reduce the amount of churn, and minimize the number of commits that were reverted. I've also manually updated merge conflicts and manually arranged for the getIntPtrType function to stay in DataLayout and to be defined in a plausible way after this revert. Thanks to Duncan for working through this exact strategy with me, and Nick Lewycky for tracking down the really annoying crasher this triggered. (Test case to follow in its own commit.) After discussing with Duncan extensively, and based on a note from Micah, I'm going to continue to back out some more of the more problematic patches in this series in order to ensure we go into the LLVM 3.2 branch with a reasonable story here. I'll send a note to llvmdev explaining what's going on and why. Summary of reverted revisions: r166634: Fix a compiler warning with an unused variable. r166607: Add some cleanup to the DataLayout changes requested by Chandler. r166596: Revert "Back out r166591, not sure why this made it through since I cancelled the command. Bleh, sorry about this! r166591: Delete a directory that wasn't supposed to be checked in yet. r166578: Add in support for getIntPtrType to get the pointer type based on the address space. llvm-svn: 167221
* LoopVectorize: Preserve NSW, NUW and IsExact flags.Nadav Rotem2012-10-317-7/+62
| | | | llvm-svn: 167174
* Fix a bug in the cost calculation of vector casts. Detect situations where ↵Nadav Rotem2012-10-311-0/+48
| | | | | | bitcasts cost zero. llvm-svn: 167170
* Remove fixme about unreachable cases from SwitchToLookupTableHans Wennborg2012-10-311-0/+32
| | | | | | SimplifyCFG will have removed those cases for us. llvm-svn: 167132
* BBVectorize: Choose pair ordering to minimize shufflesHal Finkel2012-10-319-21/+46
| | | | | | | | | | | | | | | | | | | | BBVectorize would, except for loads and stores, always fuse instructions so that the first instruction (in the current source order) would always represent the low part of the input vectors and the second instruction would always represent the high part. This lead to too many shuffles being produced because sometimes the opposite order produces fewer of them. With this change, BBVectorize tracks the kind of pair connections that form the DAG of candidate pairs, and uses that information to reorder the pairs to avoid excess shuffles. Using this information, a future commit will be able to add VTTI-based shuffle costs to the pair selection procedure. Importantly, the number of remaining shuffles can now be estimated during pair selection. There are some trivial instruction reorderings in the test cases, and one simple additional test where we certainly want to do a reordering to avoid an unnecessary shuffle. llvm-svn: 167122
* instcombine: Migrate strto* optimizationsMeador Inge2012-10-312-14/+82
| | | | | | | This patch migrates the strto* optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167119
* Do simple constant propagation in lookup table formation for switchesHans Wennborg2012-10-311-0/+41
| | | | | | | | | | | | | | | | | | | By propagating the value for the switch condition, LLVM can now build lookup tables for code such as: switch (x) { case 1: return 5; case 2: return 42; case 3: case 4: case 5: return x - 123; default: return 123; } Given that x is known for each case, "x - 123" becomes a constant for cases 3, 4, and 5. llvm-svn: 167115
* LCSSA: Add a workaround for another nasty SCEV cache invalidation issue.Benjamin Kramer2012-10-311-0/+74
| | | | | | | I'm not entirely happy with this solution, but I don't see a smarter way currently. Fixes PR14214. llvm-svn: 167112
* DependenceAnalysis: Don't crash if there is no constant operand.Benjamin Kramer2012-10-311-0/+25
| | | | | | This makes the code match the comments. Resolves a crash in loop idiom (PR14219). llvm-svn: 167110
* instcombine: Migrate strpbrk optimizationsMeador Inge2012-10-313-25/+91
| | | | | | | This patch migrates the strpbrk optimizations from the simplify-libcalls pass into the instcombine library call simplifier. llvm-svn: 167105
OpenPOWER on IntegriCloud