summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* 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> llvm-svn: 160954
* Add testcases for GlobalOpt changes in r160693 and r160757.Nick Lewycky2012-07-291-3/+33
| | | | llvm-svn: 160925
* fix PR13390: do not loop forever with self-referencing self instructionsNuno Lopes2012-07-271-0/+19
| | | | llvm-svn: 160876
* 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 llvm-svn: 160874
* Simplify demanded bits of select sources where the condition is a constant ↵Pete Cooper2012-07-261-0/+19
| | | | | | vector llvm-svn: 160835
* Teach SimplifyDemandedBits how to look through fpext and fptrunc to simplify ↵Pete Cooper2012-07-261-0/+28
| | | | | | their operand llvm-svn: 160823
* 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. llvm-svn: 160778
* 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. llvm-svn: 160714
* 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. llvm-svn: 160711
* teach objectsize about strdup() and strndup()Nuno Lopes2012-07-241-0/+48
| | | | llvm-svn: 160676
* 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. llvm-svn: 160664
* An objc_retain can serve as a may-use for a different pointer.Dan Gohman2012-07-231-0/+24
| | | | | | rdar://11931823. llvm-svn: 160637
* Revert r160602.Nick Lewycky2012-07-212-21/+1
| | | | llvm-svn: 160603
* 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. llvm-svn: 160602
* 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. llvm-svn: 160587
* 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. llvm-svn: 160546
* Revert r160529 due to crashes.Nick Lewycky2012-07-192-21/+1
| | | | llvm-svn: 160532
* 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. llvm-svn: 160529
* Added unit test for PR13361: LSR + SCEV "hangs" on reasonably sized test.Andrew Trick2012-07-181-0/+517
| | | | llvm-svn: 160439
* 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. llvm-svn: 160421
* Back out r160101 and instead implement a dag combine to recover from ↵Evan Cheng2012-07-171-18/+0
| | | | | | instcombine transformation. llvm-svn: 160387
* 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. llvm-svn: 160367
* fix PR13339 (remove the predecessor from the unwind BB when removing an invoke)Nuno Lopes2012-07-161-0/+22
| | | | llvm-svn: 160325
* 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. llvm-svn: 160205
* 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 llvm-svn: 160101
* 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 llvm-svn: 159952
* 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) llvm-svn: 159876
* 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) llvm-svn: 159668
* Revert "IntRange:" as it appears to be breaking self hosting.Eric Christopher2012-07-021-1/+1
| | | | | | This reverts commit b2833d9dcba88c6f0520cad760619200adc0442c. llvm-svn: 159618
* 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. =/ llvm-svn: 159547
* GlobalOpt forgot to handle bitcast when analyzing globals. Found by inspection.Duncan Sands2012-07-021-1/+3
| | | | llvm-svn: 159546
* Convert the uses of '|&' to use '2>&1 |' instead, which works on oldChandler Carruth2012-07-0211-12/+12
| | | | | | | | | | versions of Bash. In addition, I can back out the change to the lit built-in shell test runner to support this. This should fix the majority of fallout on Darwin, but I suspect there will be a few straggling issues. llvm-svn: 159544
* fix the regression I introduced in r159385 (it's necessary to update PHI ↵Nuno Lopes2012-07-021-0/+33
| | | | | | nodes in unwind BB llvm-svn: 159534
* IntRange:Stepan Dyatkovskiy2012-07-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | - Changed isSingleNumber method behaviour. Now this flag is calculated on demand. IntegersSubsetMapping - Optimized diff operation. - Replaced type of Items field from std::list with std::map. - Added new methods: bool isOverlapped(self &RHS) void add(self& RHS, SuccessorClass *S) void detachCase(self& NewMapping, SuccessorClass *Succ) void removeCase(SuccessorClass *Succ) SuccessorClass *findSuccessor(const IntTy& Val) const IntTy* getCaseSingleNumber(SuccessorClass *Succ) IntegersSubsetTest - DiffTest: Added checks for successors. SimplifyCFG Updated SwitchInst usage (now it is case-ragnes compatible) for - SimplifyEqualityComparisonWithOnlyPredecessor - FoldValueComparisonIntoPredecessors llvm-svn: 159527
* Convert all tests using TCL-style quoting to use shell-style quoting.Chandler Carruth2012-07-02195-232/+232
| | | | | | | | | | | | | | | | | | | | | | | | This was done through the aid of a terrible Perl creation. I will not paste any of the horrors here. Suffice to say, it require multiple staged rounds of replacements, state carried between, and a few nested-construct-parsing hacks that I'm not proud of. It happens, by luck, to be able to deal with all the TCL-quoting patterns in evidence in the LLVM test suite. If anyone is maintaining large out-of-tree test trees, feel free to poke me and I'll send you the steps I used to convert things, as well as answer any painful questions etc. IRC works best for this type of thing I find. Once converted, switch the LLVM lit config to use ShTests the same as Clang. In addition to being able to delete large amounts of Python code from 'lit', this will also simplify the entire test suite and some of lit's architecture. Finally, the test suite runs 33% faster on Linux now. ;] For my 16-hardware-thread (2x 4-core xeon e5520): 36s -> 24s llvm-svn: 159525
* Fix a reassociate crash on sozefx when compiling with dragonegg+gcc-4.7 due toDuncan Sands2012-06-291-0/+11
| | | | | | | the optimizers producing a multiply expression with more multiplications than the original (!). llvm-svn: 159426
* make simplifyCFG erase invokes to readonly/readnone functionsNuno Lopes2012-06-281-1/+40
| | | | llvm-svn: 159385
* make instcombine produce calls to llvm.donothing instead of a random intrinsicNuno Lopes2012-06-281-1/+1
| | | | llvm-svn: 159384
* make LazyValueInfo analyze the default case of switch statements (we know ↵Nuno Lopes2012-06-281-0/+23
| | | | | | that in the default branch the value cannot be any of the switch cases) llvm-svn: 159353
* Allow BBVectorize to form non-2^n-length vectors.Hal Finkel2012-06-282-2/+36
| | | | | | | | | | | | | | | | | | | | The original algorithm only used recursive pair fusion of equal-length types. This is now extended to allow pairing of any types that share the same underlying scalar type. Because we would still generally prefer the 2^n-length types, those are formed first. Then a second set of iterations form the non-2^n-length types. Also, a call to SimplifyInstructionsInBlock has been added after each pairing iteration. This takes care of DCE (and a few other things) that make the following iterations execute somewhat faster. For the same reason, some of the simple shuffle-combination cases are now handled internally. There is some additional refactoring work to be done, but I've had many requests for this feature, so additional refactoring will come soon in future commits (as will additional test cases). llvm-svn: 159330
* make LVI::getEdgeValue() always intersect the constraints of the edge with ↵Nuno Lopes2012-06-281-0/+44
| | | | | | the range of the block. Previously it was only performing the intersection for a few cases, thus losing precision llvm-svn: 159320
* Revert r159136 due to PR13124.Matt Beaumont-Gay2012-06-271-14/+0
| | | | | | | | | | | Original commit message: If a constant or a function has linkonce_odr linkage and unnamed_addr, mark it hidden. Being linkonce_odr guarantees that it is available in every dso that needs it. Being a constant/function with unnamed_addr guarantees that the copies don't have to be merged. llvm-svn: 159272
* Some reassociate optimizations create new instructions, which they insert justDuncan Sands2012-06-271-0/+14
| | | | | | | | | | | before the expression root. Any existing operators that are changed to use one of them needs to be moved between it and the expression root, and recursively for the operators using that one. When I rewrote RewriteExprTree I accidentally inverted the logic, resulting in the compacting going down from operators to operands rather than up from operands to the operators using them, oops. Fix this, resolving PR12963. llvm-svn: 159265
* Remove a instcombine transform that (no longer?) makes sense:Evan Cheng2012-06-262-28/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | // C - zext(bool) -> bool ? C - 1 : C if (ZExtInst *ZI = dyn_cast<ZExtInst>(Op1)) if (ZI->getSrcTy()->isIntegerTy(1)) return SelectInst::Create(ZI->getOperand(0), SubOne(C), C); This ends up forming sext i1 instructions that codegen to terrible code. e.g. int blah(_Bool x, _Bool y) { return (x - y) + 1; } => movzbl %dil, %eax movzbl %sil, %ecx shll $31, %ecx sarl $31, %ecx leal 1(%rax,%rcx), %eax ret Without the rule, llvm now generates: movzbl %sil, %ecx movzbl %dil, %eax incl %eax subl %ecx, %eax ret It also helps with ARM (and pretty much any target that doesn't have a sext i1 :-). The transformation was done as part of Eli's r75531. He has given the ok to remove it. rdar://11748024 llvm-svn: 159230
* Replacing zero-sized alloca's with a null pointer is too aggressive, insteadDuncan Sands2012-06-261-1/+7
| | | | | | | | | | | | | | | | merge all zero-sized alloca's into one, fixing c43204g from the Ada ACATS conformance testsuite. What happened there was that a variable sized object was being allocated on the stack, "alloca i8, i32 %size". It was then being passed to another function, which tested that the address was not null (raising an exception if it was) then manipulated %size bytes in it (load and/or store). The optimizers cleverly managed to deduce that %size was zero (congratulations to them, as it isn't at all obvious), which made the alloca zero size, causing the optimizers to replace it with null, which then caused the check mentioned above to fail, and the exception to be raised, wrongly. Note that no loads and stores were actually being done to the alloca (the loop that does them is executed %size times, i.e. is not executed), only the not-null address check. llvm-svn: 159202
* Enable the new LoopInfo algorithm by default.Andrew Trick2012-06-264-28/+28
| | | | | | | | | | | | | | | | | | | | | | | | The primary advantage is that loop optimizations will be applied in a stable order. This helps debugging and unit test creation. It is also a better overall implementation without pathologically bad performance on deep functions. On large functions (llvm-stress --size=200000 | opt -loops) Before: 0.1263s After: 0.0225s On deep functions (after tweaking llvm-stress, thanks Nadav): Before: 0.2281s After: 0.0227s See r158790 for more comments. The loop tree is now consistently generated in forward order, but loop passes are applied in reverse order over the program. If we have a loop optimization that prefers forward order, that can easily be achieved by adding a different type of LoopPassManager. llvm-svn: 159183
* revert my previous commit (r159173), since as Eli pointed out, it's ↵Nuno Lopes2012-06-251-1/+1
| | | | | | perfectly ok to mark realloc as noalias llvm-svn: 159175
* do not set realloc() as NotAlias, since it can return the same pointer. This ↵Nuno Lopes2012-06-251-1/+1
| | | | | | whole thing should be upgraded to use the MemoryBuiltin interface anyway.. llvm-svn: 159173
* Fix the objc_autoreleasedReturnValue optimization code to locateDan Gohman2012-06-251-4/+31
| | | | | | | the call correctly even in the case where it is an invoke. This fixes rdar://11714057. llvm-svn: 159157
* improve optimization of invoke instructions:Nuno Lopes2012-06-252-1/+46
| | | | | | | | - simplifycfg: invoke undef/null -> unreachable - instcombine: invoke new -> invoke expect(0, 0) (an arbitrary NOOP intrinsic; only done if the allocated memory is unused, of course) - verifier: allow invoke of intrinsics (to make the previous step work) llvm-svn: 159146
OpenPOWER on IntegriCloud