summaryrefslogtreecommitdiff
path: root/test/Transforms
Commit message (Collapse)AuthorAge
* Get rid of the getPointeeAlignment helper function fromEli Friedman2012-11-26
| | | | | | | | | | InstCombineLoadStoreAlloca.cpp, which had many issues. (At least two bugs were noted on llvm-commits, and it was overly conservative.) Instead, use getOrEnforceKnownAlignment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168629 91177308-0d34-0410-b5e6-96231b3b80d8
* rdar://12329730 (defect 2)Shuxin Yang2012-11-26
| | | | | | | | | | | | | | | Enhancement to InstCombine. Try to catch this opportunity: --------------------------------------------------------------- ((X^C1) >> C2) ^ C3 => (X>>C2) ^ ((C1>>C2)^C3) where the subexpression "X ^ C1" has more than one uses, and "(X^C1) >> C2" has single use. ---------------------------------------------------------------- Reviewed by Nadav (with minor change per his request). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168615 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Migrate printf optimizationsMeador Inge2012-11-26
| | | | | | | This patch migrates the printf optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168604 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Migrate toascii optimizationsMeador Inge2012-11-26
| | | | | | | This patch migrates the toascii optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168580 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Migrate isascii optimizationsMeador Inge2012-11-26
| | | | | | | This patch migrates the isascii optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168579 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Migrate isdigit optimizationsMeador Inge2012-11-26
| | | | | | | This patch migrates the isdigit optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168578 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix bogus comment; no functional change.Meador Inge2012-11-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168575 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Migrate *abs optimizationsMeador Inge2012-11-26
| | | | | | | This patch migrates the *abs optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168574 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Migrate ffs* optimizationsMeador Inge2012-11-25
| | | | | | | This patch migrates the ffs* optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168571 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for pointer induction variables even when there is no integer ↵Nadav Rotem2012-11-25
| | | | | | induction variable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168558 91177308-0d34-0410-b5e6-96231b3b80d8
* Disallow the undocumented practice of starting the datalayout string with '-'.Patrik Hägglund2012-11-23
| | | | | | | Update some test cases accordingly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168516 91177308-0d34-0410-b5e6-96231b3b80d8
* Add more functions to the target library information.Meador Inge2012-11-22
| | | | | | | | I discovered a few more missing functions while migrating optimizations from the simplify-libcalls pass to the instcombine (I already added some in r167659). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168501 91177308-0d34-0410-b5e6-96231b3b80d8
* llvm/test/Transforms/InstCombine/sdiv-1.ll: FileCheck-ize.NAKAMURA Takumi2012-11-21
| | | | | | | | | "not grep '-715827882'" performed as below...bad... Usage: grep [OPTION]... PATTERN [FILE]... Try `grep --help' for more information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168430 91177308-0d34-0410-b5e6-96231b3b80d8
* PR14055: Implement support for sub-vector operations in SROA.Chandler Carruth2012-11-21
| | | | | | | | | | Now if we can transform an alloca into a single vector value, but it has subvector, non-element accesses, we form the appropriate shufflevectors to allow SROA to proceed. This fixes PR14055 which pointed out a very common pattern that SROA couldn't handle -- mixed vec3 and vec4 operations on a single alloca. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168418 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR14132 and handle OOB loads speculated throuh PHI nodes.Chandler Carruth2012-11-20
| | | | | | | | | | | | The issue is that we may end up with newly OOB loads when speculating a load into the predecessors of a PHI node, and this confuses the new integer splitting logic in some cases, triggering an assertion failure. In fact, the branch in question must be dead code as it loads from a too-narrow alloca. Add code to handle this gracefully and leave the requisite FIXMEs for both optimizing more aggressively and doing more to aid sanitizing invalid code which triggers these patterns. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168361 91177308-0d34-0410-b5e6-96231b3b80d8
* Rework the rewriting of loads and stores for vector and integer allocasChandler Carruth2012-11-20
| | | | | | | | | | | | | | | | | | | | | | | | | | to properly handle the combinations of these with split integer loads and stores. This essentially replaces Evan's r168227 by refactoring the code in a different way, and trynig to mirror that refactoring in both the load and store sides of the rewriting. Generally speaking there was some really problematic duplicated code here that led to poorly founded assumptions and then subtle bugs. Now much of the code actually flows through and follows a more consistent style and logical path. There is still a tiny bit of duplication on the store side of things, but it is much less bad. This also changes the logic to never re-use a load or store instruction as that was simply too error prone in practice. I've added a few tests (one a reduction of the one in Evan's original patch, which happened to be the same as the report in PR14349). I'm going to look at adding a few more tests for things I found and fixed in passing (such as the volatile tests in the vectorizable predicate). This patch has survived bootstrap, and modulo one bugfix survived Duncan's test suite, but let me know if anything else explodes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168346 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR14060, an infinite loop in reassociate. The problem was that one of theDuncan Sands2012-11-18
| | | | | | | | | | | operands of the expression being written was wrongly thought to be reusable as an inner node of the expression resulting in it turning up as both an inner node *and* a leaf, creating a cycle in the def-use graph. This would have caused the verifier to blow up if things had gotten that far, however it managed to provoke an infinite loop first. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168291 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't try to calculate the alignment of an unsigned type. Fixes PR14371!Nick Lewycky2012-11-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168280 91177308-0d34-0410-b5e6-96231b3b80d8
* LoopVectorizer: Add initial support for pointer induction variables (for ↵Nadav Rotem2012-11-17
| | | | | | | | | | example: *dst++ = *src++). At the moment we still require to have an integer induction variable (for example: i++). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168231 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach SROA rewriteVectorizedStoreInst to handle cases when the loaded value ↵Evan Cheng2012-11-17
| | | | | | is narrower than the stored value. rdar://12713675 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168227 91177308-0d34-0410-b5e6-96231b3b80d8
* InstructionSimplify should be able to simplify A+B==B+A to 'true'Duncan Sands2012-11-16
| | | | | | | but wasn't due to the same logic bug that caused PR14361. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168186 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR14361: wrong simplification of A+B==B+A. You may think that the old logicDuncan Sands2012-11-16
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168181 91177308-0d34-0410-b5e6-96231b3b80d8
* Constant::IsThreadDependent(): Use dyn_cast<Constant> instead of castHans Wennborg2012-11-16
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168147 91177308-0d34-0410-b5e6-96231b3b80d8
* Make GlobalOpt be conservative with TLS variables (PR14309)Hans Wennborg2012-11-15
| | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168037 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a crash observed by Shuxin Yang. The issue here is that LinearizeExprTree,Duncan Sands2012-11-15
| | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168035 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove DOS line endings.Jakub Staszak2012-11-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167968 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the instcombine GEP index widening transform to work correctly for vectorDuncan Sands2012-11-13
| | | | | | | getelementptrs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167829 91177308-0d34-0410-b5e6-96231b3b80d8
* Relax the restrictions on vector of pointer types, and vector getelementptr.Duncan Sands2012-11-13
| | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167828 91177308-0d34-0410-b5e6-96231b3b80d8
* Figure out <size> argument of llvm.lifetime intrinsics at the moment they ↵Alexey Samsonov2012-11-13
| | | | | | are created (during function inlining) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167821 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Migrate math library call simplificationsMeador Inge2012-11-13
| | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167815 91177308-0d34-0410-b5e6-96231b3b80d8
* BBVectorize: Don't vectorize vector-manipulation chainsHal Finkel2012-11-13
| | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167811 91177308-0d34-0410-b5e6-96231b3b80d8
* revert r167740Shuxin Yang2012-11-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167787 91177308-0d34-0410-b5e6-96231b3b80d8
* BBVectorize: Only some insert element operand pairs are free.Hal Finkel2012-11-12
| | | | | | | | 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). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167784 91177308-0d34-0410-b5e6-96231b3b80d8
* BBVectorize: Use a more sophisticated check for input costHal Finkel2012-11-12
| | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167750 91177308-0d34-0410-b5e6-96231b3b80d8
* BBVectorize: Check the types of compare instructionsHal Finkel2012-11-12
| | | | | | | The pass would previously assert when trying to compute the cost of compare instructions with illegal vector types (like struct pointers). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167743 91177308-0d34-0410-b5e6-96231b3b80d8
* This change is to fix rdar://12571717 which is about assertion in ↵Shuxin Yang2012-11-12
| | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167740 91177308-0d34-0410-b5e6-96231b3b80d8
* BBVectorize: Check the input types of shuffles for legalityHal Finkel2012-11-12
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167731 91177308-0d34-0410-b5e6-96231b3b80d8
* Normalize memcmp constant folding results.Meador Inge2012-11-12
| | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167726 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove hard-coded constant in Transforms/InstCombine/memcmp-1.llMeador Inge2012-11-11
| | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167691 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Migrate memset optimizationsMeador Inge2012-11-11
| | | | | | | This patch migrates the memset optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167689 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Migrate memmove optimizationsMeador Inge2012-11-11
| | | | | | | This patch migrates the memmove optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167687 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Migrate memcpy optimizationsMeador Inge2012-11-11
| | | | | | | This patch migrates the memcpy optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167686 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Migrate memcmp optimizationsMeador Inge2012-11-11
| | | | | | | This patch migrates the memcmp optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167683 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Migrate strstr optimizationsMeador Inge2012-11-11
| | | | | | | This patch migrates the strstr optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167682 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Migrate strcspn optimizationsMeador Inge2012-11-10
| | | | | | | This patch migrates the strcspn optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167675 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Query target library information to gate libcall simplificationsMeador Inge2012-11-10
| | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167660 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for memory runtime check. When we can, we calculate array bounds.Nadav Rotem2012-11-09
| | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167608 91177308-0d34-0410-b5e6-96231b3b80d8
* llvm/ConstantFolding.cpp: Make ReadDataFromGlobal() and ↵NAKAMURA Takumi2012-11-08
| | | | | | FoldReinterpretLoadFromConstPtr() Big-endian-aware. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167595 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: Migrate strspn optimizationsMeador Inge2012-11-08
| | | | | | | This patch migrates the strspn optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167568 91177308-0d34-0410-b5e6-96231b3b80d8
* Only do switch-to-lookup table transformation when TargetTransformInfoHans Wennborg2012-11-07
| | | | | | is available. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167552 91177308-0d34-0410-b5e6-96231b3b80d8