aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* Port the global copy optimization from the SROA pass to InstCombine.Chandler Carruth2012-08-211-20/+10
| | | | | | | | | | This optimization is really just replacing allocas wholesale with globals, there is no scalarization. The underlying motivation for this patch is to simplify the SROA pass and focus it on splitting and promoting allocas. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162271 91177308-0d34-0410-b5e6-96231b3b80d8
* InstCombine: Fix a crasher when encountering a function pointer.Benjamin Kramer2012-08-181-0/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162180 91177308-0d34-0410-b5e6-96231b3b80d8
* InstCombine: Add a couple of fabs identities for comparing with 0.0.Benjamin Kramer2012-08-181-0/+82
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162174 91177308-0d34-0410-b5e6-96231b3b80d8
* SimplifyLibcalls: Add fabs and trunc to the list of libcalls that are safe ↵Benjamin Kramer2012-08-181-0/+23
| | | | | | to shrink from double to float. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162173 91177308-0d34-0410-b5e6-96231b3b80d8
* MemoryBuiltins: Properly guard ObjectSizeOffsetVisitor against cycles in the IR.Benjamin Kramer2012-08-171-1/+2
| | | | | | | | | | The previous fix only checked for simple cycles, use a set to catch longer cycles too. Drop the broken check from the ObjectSizeOffsetEvaluator. The BoundsChecking pass doesn't have to deal with invalid IR like InstCombine does. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162120 91177308-0d34-0410-b5e6-96231b3b80d8
* Guard MemoryBuiltins against self-looping GEPs, which can occur in ↵Benjamin Kramer2012-08-171-0/+17
| | | | | | | | unreachable code due to constant propagation. Fixes PR13621. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162098 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix broken check lines.Benjamin Kramer2012-08-174-10/+9
| | | | | | | | I really need to find a way to automate this, but I can't come up with a regex that has no false positives while handling tricky cases like custom check prefixes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162097 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach GVN to reason about edges dominating uses. This allows it to handle casesRafael Espindola2012-08-161-0/+60
| | | | | | | | | | | | | where some fact lake a=b dominates a use in a phi, but doesn't dominate the basic block itself. This feature could also be implemented by splitting critical edges, but at least with the current algorithm reasoning about the dominance directly is faster. The time for running "opt -O2" in the testcase in pr10584 is 1.003 times slower and on gcc as a single file it is 1.0007 times faster. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162023 91177308-0d34-0410-b5e6-96231b3b80d8
* fix infinite loop in instcombine with more than 4GB memcpyMichael Liao2012-08-151-0/+8
| | | | | | | | | | | | | | - memcpy size is wrongly truncated into 32-bit and treat 8GB memcpy is 0-sized memcpy - as 0-sized memcpy/memset is already removed before SimplifyMemTransfer and SimplifyMemSet in visitCallInst, replace 0 checking with assertions. - replace getZExtValue() with getLimitedValue() according to Eli Friedman git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161923 91177308-0d34-0410-b5e6-96231b3b80d8
* Change greater than to greater than or equal so that an identical sized ↵Craig Topper2012-08-141-0/+19
| | | | | | store to the same offset is treated as completing overwriting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161857 91177308-0d34-0410-b5e6-96231b3b80d8
* During the CodeGenPrepare we often lower intrinsics (such as objsize)Nadav Rotem2012-08-142-7/+7
| | | | | | | | | | | | | and allow some optimizations to turn conditional branches into unconditional. This commit adds a simple control-flow optimization which merges two consecutive basic blocks which are connected by a single edge. This allows the codegen to operate on larger basic blocks. rdar://11973998 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161852 91177308-0d34-0410-b5e6-96231b3b80d8
* The normal edge of an invoke is not allowed to branch to a block with aEli Friedman2012-08-105-1170/+7
| | | | | | | | landingpad. Enforce it in the verifier, and fix the regression tests to match. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161697 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix crash when when do lto on Bullet. Dynamic GEPs in SROA were incorrectly ↵Pete Cooper2012-08-101-0/+22
| | | | | | being applied to all accesses to an alloca, not just the ones which read from the GEP. Thanks to Evan for reducing the test. rdar://11861001 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161654 91177308-0d34-0410-b5e6-96231b3b80d8
* isAllocLikeFn is allowed to return true for functions which read memory; makeEli Friedman2012-08-081-0/+15
| | | | | | | | | sure we account for that correctly in DeadStoreElimination. Fixes a regression from r158919. PR13547. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161468 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid recomputing the unique exit blocks and their insert points when doingDan Gohman2012-08-081-0/+41
| | | | | | | | | | multiple scalar promotions on a single loop. This also has the effect of preserving the order of stores sunk out of loops, which is aesthetically pleasing, and it happens to fix the testcase in PR13542, though it doesn't fix the underlying problem. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161459 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a serious typo in InstCombine's optimization of comparisons.Bob Wilson2012-08-071-0/+9
| | | | | | | | | An unsigned value converted to floating-point will always be greater than a negative constant. Unfortunately InstCombine reversed the check so that unsigned values were being optimized to always be greater than all positive floating-point constants. <rdar://problem/12029145> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161452 91177308-0d34-0410-b5e6-96231b3b80d8
* PR13095: Give an inline cost bonus to functions using byval arguments.Benjamin Kramer2012-08-071-0/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | | We give a bonus for every argument because the argument setup is not needed anymore when the function is inlined. With this patch we interpret byval arguments as a compact representation of many arguments. The byval argument setup is implemented in the backend as an inline memcpy, so to model the cost as accurately as possible we take the number of pointer-sized elements in the byval argument and give a bonus of 2 instructions for every one of those. The bonus is capped at 8 elements, which is the number of stores at which the x86 backend switches from an expanded inline memcpy to a real memcpy. It would be better to use the real memcpy threshold from the backend, but it's not available via TargetData. This change brings the performance of c-ray in line with gcc 4.7. The included test case tries to reproduce the c-ray problem to catch regressions for this benchmark early, its performance is dominated by the inline decision of a specific call. This only has a small impact on most code, more on x86 and arm than on x86_64 due to the way the ABI works. When building LLVM for x86 it gives a small inline cost boost to virtually any function using StringRef or STL allocators, but only a 0.01% increase in overall binary size. The size of gcc compiled by clang actually shrunk by a couple bytes with this patch applied, but not significantly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161413 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR13412, a nasty miscompile due to the interleavedChandler Carruth2012-08-071-0/+62
| | | | | | | | | | | | | | | | | | instsimplify+inline strategy. The crux of the problem is that instsimplify was reasonably relying on an invariant that is true within any single function, but is no longer true mid-inline the way we use it. This invariant is that an argument pointer != a local (alloca) pointer. The fix is really light weight though, and allows instsimplify to be resiliant to these situations: when checking the relation ships to function arguments, ensure that the argumets come from the same function. If they come from different functions, then none of these assumptions hold. All credit to Benjamin Kramer for coming up with this clever solution to the problem. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161410 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a much more conservative strategy for aligning branch targets.Chandler Carruth2012-08-071-1/+0
| | | | | | | | | | | | | Previously, MBP essentially aligned every branch target it could. This bloats code quite a bit, especially non-looping code which has no real reason to prefer aligned branch targets so heavily. As Andy said in review, it's still a bit odd to do this without a real cost model, but this at least has much more plausible heuristics. Fixes PR13265. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161409 91177308-0d34-0410-b5e6-96231b3b80d8
* When constant folding GEP expressions, keep the address space information of ↵Nadav Rotem2012-07-301-0/+10
| | | | | | | | | | pointers. Together with Ran Chachick <ran.chachick@intel.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160954 91177308-0d34-0410-b5e6-96231b3b80d8
* Add testcases for GlobalOpt changes in r160693 and r160757.Nick Lewycky2012-07-291-3/+33
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160925 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR13390: do not loop forever with self-referencing self instructionsNuno Lopes2012-07-271-0/+19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160876 91177308-0d34-0410-b5e6-96231b3b80d8
* fix infinite loop in instcombine in the presence of a (malformed) ↵Nuno Lopes2012-07-271-0/+17
| | | | | | | | self-referencing select inst. This can happen as long as the instruction is not reachable. Instcombine does generate these unreachable malformed selects when doing RAUW git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160874 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify demanded bits of select sources where the condition is a constant ↵Pete Cooper2012-07-261-0/+19
| | | | | | vector git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160835 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach SimplifyDemandedBits how to look through fpext and fptrunc to simplify ↵Pete Cooper2012-07-261-0/+28
| | | | | | their operand git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160823 91177308-0d34-0410-b5e6-96231b3b80d8
* Stop reassociate from looking through expressions of arbitrary complexity. ThisDuncan Sands2012-07-262-0/+37
| | | | | | | is a temporary measure until my fix for PR13021 is ready. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160778 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't perform an overaligned load in this test, since that's undefinedDuncan Sands2012-07-251-1/+1
| | | | | | | behaviour that might be exploited one day. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160714 91177308-0d34-0410-b5e6-96231b3b80d8
* When folding a load from a global constant, if the load started in the middleDuncan Sands2012-07-251-0/+12
| | | | | | | | | | | of an array element (rather than at the beginning of the element) and extended into the next element, then the load from the second element was being handled wrong due to incorrect updating of the notion of which byte to load next. This fixes PR13442. Thanks to Chris Smowton for reporting the problem, analyzing it and providing a fix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160711 91177308-0d34-0410-b5e6-96231b3b80d8
* teach objectsize about strdup() and strndup()Nuno Lopes2012-07-241-0/+48
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160676 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach globalopt to not nuke all stores to globals. Keep them around of theyNick Lewycky2012-07-242-1/+20
| | | | | | | | | | might be deliberate "one time" leaks, so that leak checkers can find them. This is a reapply of r160602 with the fix that this time I'm committing the code I thought I was committing last time; the I->eraseFromParent() goes *after* the break out of the loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160664 91177308-0d34-0410-b5e6-96231b3b80d8
* An objc_retain can serve as a may-use for a different pointer.Dan Gohman2012-07-231-0/+24
| | | | | | | rdar://11931823. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160637 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r160602.Nick Lewycky2012-07-212-21/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160603 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach globalopt to play nice with leak checkers. This is a reapplication ofNick Lewycky2012-07-212-1/+21
| | | | | | | | | r160529 that was subsequently reverted. The fix was to not call GV->eraseFromParent() right before the caller does the same. The existing testcases already caught this bug if run under valgrind. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160602 91177308-0d34-0410-b5e6-96231b3b80d8
* move the bounds checking pass to the instrumentation folder, where it ↵Nuno Lopes2012-07-204-187/+0
| | | | | | | | belongs. I dunno why in the world I dropped it in the Scalar folder in the first place. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160587 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix assertion in jump threading (PR13405).Richard Osborne2012-07-201-0/+8
| | | | | | | | | | GetBestDestForJumpOnUndef() assumes there is at least 1 successor, which isn't true if the block ends in an indirect branch with no successors. Fix this by bailing out earlier in this case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160546 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r160529 due to crashes.Nick Lewycky2012-07-192-21/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160532 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't wipe out global variables that are probably storing pointers to heapNick Lewycky2012-07-192-1/+21
| | | | | | | memory. This makes clang play nice with leak checkers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160529 91177308-0d34-0410-b5e6-96231b3b80d8
* Added unit test for PR13361: LSR + SCEV "hangs" on reasonably sized test.Andrew Trick2012-07-181-0/+517
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160439 91177308-0d34-0410-b5e6-96231b3b80d8
* indvars: Linear function test replace should avoid reusing undef.Andrew Trick2012-07-182-4/+29
| | | | | | | | | | | | | | | | | | | | | | | Fixes PR13371: indvars pass incorrectly substitutes 'undef' values. I do not like this fix. It's needed until/unless the meaning of undef changes. It attempts to be complete according to the IR spec, but I don't have much confidence in the implementation given the difficulty testing undefined behavior. Worse, this invalidates some of my hard-fought work on indvars and LSR to optimize pointer induction variables. It results benchmark regressions, which I'll track internally. On x86_64 no LTO I see: -3% huffbench -3% 400.perlbench -8% fhourstones My only suggestion for recovering is to change the meaning of undef. If we could trust an arbitrary instruction to produce a some real value that can be manipulated (e.g. incremented) according to non-undef rules, then this case could be easily handled with SCEV. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160421 91177308-0d34-0410-b5e6-96231b3b80d8
* Back out r160101 and instead implement a dag combine to recover from ↵Evan Cheng2012-07-171-18/+0
| | | | | | instcombine transformation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160387 91177308-0d34-0410-b5e6-96231b3b80d8
* llvm/test/Transforms/LoopRotate/PhiRename-1.ll: FileCheck-ize. It fixes PR13301.NAKAMURA Takumi2012-07-171-2/+3
| | | | | | It began choking since Chandler's r159547, possibly due to improper expression on grep from TclParser to ShParser. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160367 91177308-0d34-0410-b5e6-96231b3b80d8
* fix PR13339 (remove the predecessor from the unwind BB when removing an invoke)Nuno Lopes2012-07-161-0/+22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160325 91177308-0d34-0410-b5e6-96231b3b80d8
* LSR Fix: check SCEV expression safety before expansion.Andrew Trick2012-07-131-0/+90
| | | | | | | | | | All SCEV expressions used by LSR formulae must be safe to expand. i.e. they may not contain UDiv unless we can prove nonzero denominator. Fixes PR11356: LSR hoists UDiv. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160205 91177308-0d34-0410-b5e6-96231b3b80d8
* Instcombine was transforming:Evan Cheng2012-07-121-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | %shr = lshr i64 %key, 3 %0 = load i64* %val, align 8 %sub = add i64 %0, -1 %and = and i64 %sub, %shr ret i64 %and to: %shr = lshr i64 %key, 3 %0 = load i64* %val, align 8 %sub = add i64 %0, 2305843009213693951 %and = and i64 %sub, %shr ret i64 %and The demanded bit optimization is actually a pessimization because add -1 would be codegen'ed as a sub 1. Teach the demanded constant shrinking optimization to check for negated constant to make sure it is actually reducing the width of the constant. rdar://11793464 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160101 91177308-0d34-0410-b5e6-96231b3b80d8
* instcombine: merge the functions that remove dead allocas and dead ↵Nuno Lopes2012-07-091-1/+2
| | | | | | | | | mallocs/callocs/... This patch removes ~70 lines in InstCombineLoadStoreAlloca.cpp and makes both functions a bit more aggressive than before :) In theory, we can be more aggressive when removing an alloca than a malloc, because an alloca pointer should never escape, but we are not taking advantage of this anyway git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159952 91177308-0d34-0410-b5e6-96231b3b80d8
* teach instcombine to remove allocated buffers even if there are stores, ↵Nuno Lopes2012-07-065-15/+103
| | | | | | | | | | | | memcpy/memmove/memset, and objectsize users. This means we can do cheap DSE for heap memory. Nothing is done if the pointer excapes or has a load. The churn in the tests is mostly due to objectsize, since we want to make sure we don't delete the malloc call before evaluating the objectsize (otherwise it becomes -1/0) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159876 91177308-0d34-0410-b5e6-96231b3b80d8
* BoundsChecking: optimize out the check for offset < 0 if size is known to ↵Nuno Lopes2012-07-031-2/+6
| | | | | | | | be >= 0 (signed). (LLVM optimizers cannot do this optimization by themselves) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159668 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "IntRange:" as it appears to be breaking self hosting.Eric Christopher2012-07-021-1/+1
| | | | | | This reverts commit b2833d9dcba88c6f0520cad760619200adc0442c. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159618 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the remaining TCL-style quotes found in the testsuite. This isChandler Carruth2012-07-0271-75/+75
| | | | | | | | | | | | | | | | | another mechanical change accomplished though the power of terrible Perl scripts. I have manually switched some "s to 's to make escaping simpler. While I started this to fix tests that aren't run in all configurations, the massive number of tests is due to a really frustrating fragility of our testing infrastructure: things like 'grep -v', 'not grep', and 'expected failures' can mask broken tests all too easily. Essentially, I'm deeply disturbed that I can change the testsuite so radically without causing any change in results for most platforms. =/ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159547 91177308-0d34-0410-b5e6-96231b3b80d8
* GlobalOpt forgot to handle bitcast when analyzing globals. Found by inspection.Duncan Sands2012-07-021-1/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159546 91177308-0d34-0410-b5e6-96231b3b80d8