summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
Commit message (Collapse)AuthorAgeFilesLines
* Fix Doxygen issues:Dmitri Gribenko2012-09-131-1/+4
| | | | | | | | * wrap code blocks in \code ... \endcode; * refer to parameter names in paragraphs correctly (\arg is not what most people want -- it starts a new paragraph). llvm-svn: 163790
* Detect overflow in the path count computation. rdar://12277446.Dan Gohman2012-09-121-0/+13
| | | | llvm-svn: 163739
* Release build: guard dump functions withManman Ren2012-09-122-8/+8
| | | | | | | | "#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)" No functional change. Update r163344. llvm-svn: 163679
* Move spaces to the right places. No functionality change.Nick Lewycky2012-09-091-4/+4
| | | | llvm-svn: 163485
* DSE: Poking holes into a SetVector is expensive, avoid it if possible.Benjamin Kramer2012-09-091-5/+5
| | | | llvm-svn: 163480
* Release build: guard dump functions with "ifndef NDEBUG"Manman Ren2012-09-062-0/+16
| | | | | | No functional change. llvm-svn: 163344
* Update function names to conform to guidelines.Jim Grosbach2012-09-061-26/+26
| | | | | | No functional change. llvm-svn: 163279
* Make provenance checking conservative in cases whenDan Gohman2012-09-041-37/+42
| | | | | | | | pointers-to-strong-pointers may be in play. These can lead to retains and releases happening in unstructured ways, foiling the optimizer. This fixes rdar://12150909. llvm-svn: 163180
* Generic Bypass Slow DivPreston Gurd2012-09-041-1/+14
| | | | | | | | | | | | | | | | | | | | | | | - CodeGenPrepare pass for identifying div/rem ops - Backend specifies the type mapping using addBypassSlowDivType - Enabled only for Intel Atom with O2 32-bit -> 8-bit - Replace IDIV with instructions which test its value and use DIVB if the value is positive and less than 256. - In the case when the quotient and remainder of a divide are used a DIV and a REM instruction will be present in the IR. In the non-Atom case they are both lowered to IDIVs and CSE removes the redundant IDIV instruction, using the quotient and remainder from the first IDIV. However, due to this optimization CSE is not able to eliminate redundant IDIV instructions because they are located in different basic blocks. This is overcome by calculating both the quotient (DIV) and remainder (REM) in each basic block that is inserted by the optimization and reusing the result values when a subsequent DIV or REM instruction uses the same operands. - Test cases check for the presents of the optimization when calculating either the quotient, remainder, or both. Patch by Tyler Nowicki! llvm-svn: 163150
* LICM may hoist an instruction with undefined behavior above a trap.Nadav Rotem2012-09-041-7/+30
| | | | | | | | | | Scan the body of the loop and find instructions that may trap. Use this information when deciding if it is safe to hoist or sink instructions. Notice that we can optimize the search of instructions that may throw in the case of nested loops. rdar://11518836 llvm-svn: 163132
* Not all targets have efficient ISel code generation for select instructions.Nadav Rotem2012-09-021-7/+22
| | | | | | | | | For example, the ARM target does not have efficient ISel handling for vector selects with scalar conditions. This patch adds a TLI hook which allows the different targets to report which selects are supported well and which selects should be converted to CF duting codegen prepare. llvm-svn: 163093
* LoopRotation: Make the brute force DomTree update more brute force.Benjamin Kramer2012-09-021-32/+21
| | | | | | | | | | | | | | We update until we hit a fixpoint. This is probably slow but also slightly simplifies the code. It should also fix the occasional invalid domtrees observed when building with expensive checking. I couldn't find a case where this had a measurable slowdown, but if someone finds a pathological case where it does we may have to find a cleverer way of updating dominators here. Thanks to Duncan for the test case. llvm-svn: 163091
* LoopRotation: Check some invariants of the dominator updating code.Benjamin Kramer2012-09-011-0/+3
| | | | llvm-svn: 163058
* LoopRotate: Also rotate loops with multiple exits.Benjamin Kramer2012-08-301-13/+60
| | | | | | | | | | | | | | | The old PHI updating code in loop-rotate was replaced with SSAUpdater a while ago, it has no problems with comples PHIs. What had to be fixed is detecting whether a loop was already rotated and updating dominators when multiple exits were present. This change increases overall code size a bit, mostly due to additional loop unrolling opportunities. Passes test-suite and selfhost with -verify-dom-info. Fixes PR7447. Thanks to Andy for the input on the domtree updating code. llvm-svn: 162912
* Make MemoryBuiltins aware of TargetLibraryInfo.Benjamin Kramer2012-08-2910-38/+51
| | | | | | | | | | | | | | | | This disables malloc-specific optimization when -fno-builtin (or -ffreestanding) is specified. This has been a problem for a long time but became more severe with the recent memory builtin improvements. Since the memory builtin functions are used everywhere, this required passing TLI in many places. This means that functions that now have an optional TLI argument, like RecursivelyDeleteTriviallyDeadFunctions, won't remove dead mallocs anymore if the TLI argument is missing. I've updated most passes to do the right thing. Fixes PR13694 and probably others. llvm-svn: 162841
* Don't use for loops for code that is only intended to execute once. NoDan Gohman2012-08-271-6/+6
| | | | | | intended functionality change. Thanks to Ahmed Charles for spotting it. llvm-svn: 162686
* GVN: Fix quadratic runtime on the number of switch cases.Benjamin Kramer2012-08-241-2/+10
| | | | | | | | No intended behavior change. This was introduced in r162023. With the fixed algorithm a Release build of ARMInstPrinter.cpp goes from 16s to 10s on a 2011 MBP. llvm-svn: 162559
* SimplifyLibCalls: Give all safely-shrinkable libcalls the same treatment.Benjamin Kramer2012-08-221-5/+5
| | | | llvm-svn: 162383
* Add a few float shrinking optimizations to SimplifyLibCalls. UnsafeChad Rosier2012-08-221-36/+99
| | | | | | | optimizations are guarded by the -enable-double-float-shrink LLVM option. Last bit of PR13574. Patch by Weiming Zhao <weimingz@codeaurora.org>. llvm-svn: 162368
* Add a new helper function, AddOpt(F1, F1, Opt), as part of PR13574. NoChad Rosier2012-08-221-14/+15
| | | | | | functional change intended. Patch by Weiming Zhao <weimingz@codeaurora.org>. llvm-svn: 162363
* Don't bind a reference to a dereferenced null pointer (for return value of ↵Richard Smith2012-08-211-1/+2
| | | | | | WeakVH::operator*). llvm-svn: 162309
* Port the global copy optimization from the SROA pass to InstCombine.Chandler Carruth2012-08-211-178/+0
| | | | | | | | | | 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. llvm-svn: 162271
* revise debug output to avoid dangling pointerMichael Liao2012-08-211-1/+1
| | | | llvm-svn: 162256
* SimplifyLibcalls: Add fabs and trunc to the list of libcalls that are safe ↵Benjamin Kramer2012-08-181-0/+4
| | | | | | to shrink from double to float. llvm-svn: 162173
* Teach GVN to reason about edges dominating uses. This allows it to handle casesRafael Espindola2012-08-161-47/+48
| | | | | | | | | | | | | 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. llvm-svn: 162023
* Remove dead flag.Bill Wendling2012-08-151-9/+3
| | | | llvm-svn: 161990
* Change greater than to greater than or equal so that an identical sized ↵Craig Topper2012-08-141-1/+1
| | | | | | store to the same offset is treated as completing overwriting. llvm-svn: 161857
* During the CodeGenPrepare we often lower intrinsics (such as objsize)Nadav Rotem2012-08-141-0/+39
| | | | | | | | | | | 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 llvm-svn: 161852
* Constify some basic blocks, no functionality change.Rafael Espindola2012-08-101-8/+8
| | | | llvm-svn: 161668
* Fix crash when when do lto on Bullet. Dynamic GEPs in SROA were incorrectly ↵Pete Cooper2012-08-101-3/+8
| | | | | | 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 llvm-svn: 161654
* isAllocLikeFn is allowed to return true for functions which read memory; makeEli Friedman2012-08-081-2/+9
| | | | | | | sure we account for that correctly in DeadStoreElimination. Fixes a regression from r158919. PR13547. llvm-svn: 161468
* Avoid recomputing the unique exit blocks and their insert points when doingDan Gohman2012-08-081-11/+26
| | | | | | | | | 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. llvm-svn: 161459
* Teach CodeGenPrep to look past bitcast when it's duplicating return instructionEvan Cheng2012-07-271-3/+14
| | | | | | | | into predecessor blocks to enable tail call optimization. rdar://11958338 llvm-svn: 160894
* do null checks for a few more Emit*() functions.Nuno Lopes2012-07-261-17/+15
| | | | | | Thanks Eli for noticing. llvm-svn: 160787
* Stop reassociate from looking through expressions of arbitrary complexity. ThisDuncan Sands2012-07-261-0/+2
| | | | | | is a temporary measure until my fix for PR13021 is ready. llvm-svn: 160778
* make all Emit*() functions consult the TargetLibraryInfo information before ↵Nuno Lopes2012-07-252-41/+51
| | | | | | | | | creating a call to a library function. Update all clients to pass the TLI information around. Previous draft reviewed by Eli. llvm-svn: 160733
* Clean whitespaces.Nadav Rotem2012-07-2422-498/+500
| | | | llvm-svn: 160668
* An objc_retain can serve as a may-use for a different pointer.Dan Gohman2012-07-231-1/+4
| | | | | | rdar://11931823. llvm-svn: 160637
* Suppress a warning.Nadav Rotem2012-07-231-1/+2
| | | | llvm-svn: 160629
* Fix a typo (the the => the)Sylvestre Ledru2012-07-231-2/+2
| | | | llvm-svn: 160621
* Move the initialization of the bounds checking pass. The pass itselfChandler Carruth2012-07-221-1/+0
| | | | | | moved earlier. This fixes some layering issues. llvm-svn: 160611
* move the bounds checking pass to the instrumentation folder, where it ↵Nuno Lopes2012-07-202-210/+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/+2
| | | | | | | | 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
* indvars: drive by heuristics fix.Andrew Trick2012-07-181-1/+1
| | | | | | Minor oversight noticed by inspection. Sorry no unit test. llvm-svn: 160422
* indvars: Linear function test replace should avoid reusing undef.Andrew Trick2012-07-181-5/+67
| | | | | | | | | | | | | | | | | | | | | | | 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
* Reapply r160340. LSR: Limit CollectSubexprs.Andrew Trick2012-07-171-28/+52
| | | | | | Speculatively fix crashes by code inspection. Can't reproduce them yet. llvm-svn: 160344
* Revert "LSR: try not to blow up solving combinatorial problems brute force."Andrew Trick2012-07-171-51/+28
| | | | | | Some units tests crashed on a different platform. llvm-svn: 160341
* LSR: try not to blow up solving combinatorial problems brute force.Andrew Trick2012-07-171-28/+51
| | | | | | | | | | This places limits on CollectSubexprs to constrains the number of reassociation possibilities. It limits the recursion depth and skips over chains of nested recurrences outside the current loop. Fixes PR13361. Although underlying SCEV behavior is still potentially bad. llvm-svn: 160340
* fix PR13339 (remove the predecessor from the unwind BB when removing an invoke)Nuno Lopes2012-07-161-0/+1
| | | | llvm-svn: 160325
* LSR Fix: check SCEV expression safety before expansion.Andrew Trick2012-07-131-1/+1
| | | | | | | | | | 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
OpenPOWER on IntegriCloud