summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* Fix SpeculativelyExecuteBB to either speculate all or none of the phisDan Gohman2012-01-055-6/+55
| | | | | | | | | | | | present in the bottom of the CFG triangle, as the transformation isn't ever valuable if the branch can't be eliminated. Also, unify some heuristics between SimplifyCFG's multiple if-converters, for consistency. This fixes rdar://10627242. llvm-svn: 147630
* PR11705, part 2: globalopt shouldn't put inttoptr/ptrtoint operations into ↵Eli Friedman2012-01-051-4/+15
| | | | | | global initializers if there's an implied extension or truncation. llvm-svn: 147625
* Revert r56315. When the instruction to speculate is a load, thisDan Gohman2012-01-051-1/+1
| | | | | | | | code can incorrectly move the load across a store. This never happens in practice today, but only because the current heuristics accidentally preclude it. llvm-svn: 147623
* FileCheck hygiene.Benjamin Kramer2012-01-052-2/+2
| | | | llvm-svn: 147580
* Teach instcombine all sorts of great stuff about shifts that have exact, nuw orNick Lewycky2012-01-041-0/+54
| | | | | | nsw bits on them. llvm-svn: 147528
* Fix SCEVExpander to handle loops with no preheader when LSR gives it aAndrew Trick2012-01-021-0/+50
| | | | | | | | "phony" insertion point. Fixes rdar://10619599: "SelectionDAGBuilder shouldn't visit PHI nodes!" assert llvm-svn: 147439
* Make use of the exact bit when optimizing '(X >>exact 3) << 1' to eliminate theNick Lewycky2011-12-311-0/+18
| | | | | | | 'and' that would zero out the trailing bits, and to produce an exact shift ourselves. llvm-svn: 147391
* Change CaptureTracking to pass a Use* instead of a Value* when a value isNick Lewycky2011-12-281-0/+61
| | | | | | | | | | | | | | captured. This allows the tracker to look at the specific use, which may be especially interesting for function calls. Use this to fix 'nocapture' deduction in FunctionAttrs. The existing one does not iterate until a fixpoint and does not guarantee that it produces the same result regardless of iteration order. The new implementation builds up a graph of how arguments are passed from function to function, and uses a bottom-up walk on the argument-SCCs to assign nocapture. This gets us nocapture more often, and does so rather efficiently and independent of iteration order. llvm-svn: 147327
* Turn cos(-x) into cos(x). Patch by Alexander Malyshev!Nick Lewycky2011-12-271-0/+14
| | | | llvm-svn: 147291
* Teach simplifycfg to recompute branch weights when merging some branches, andNick Lewycky2011-12-271-2/+64
| | | | | | | to discard weights when appropriate. Still more to do (and a new TODO), but it's a start! llvm-svn: 147286
* Update the branch weight metadata when reversing the order of a branch.Nick Lewycky2011-12-261-0/+26
| | | | llvm-svn: 147280
* Add an explicit test that we now fold cttz.i32(..., true) >> 5 -> 0.Chandler Carruth2011-12-241-7/+13
| | | | | | This is a result of Benjamin's work on ValueTracking. llvm-svn: 147259
* InstCombine: Add a combine that turns (2^n)-1 ^ x back into (2^n)-1 - x iff ↵Benjamin Kramer2011-12-241-0/+12
| | | | | | | | | x is smaller than 2^n and it fuses with a following add. This was intended to undo the sub canonicalization in cases where it's not profitable, but it also finds some cases on it's own. llvm-svn: 147256
* ComputeMaskedBits: Make knownzero computation more aggressive for ctlz with ↵Benjamin Kramer2011-12-242-3/+16
| | | | | | | | | undef zero. unsigned foo(unsigned x) { return 31 - __builtin_clz(x); } now compiles into a single "bsrl" instruction on x86. llvm-svn: 147255
* InstCombine: Canonicalize (2^n)-1 - x into (2^n)-1 ^ x iff x is known to be ↵Benjamin Kramer2011-12-241-0/+12
| | | | | | | | | | | smaller than 2^n. This has the obvious advantage of being commutable and is always a win on x86 because const - x wastes a register there. On less weird architectures this may lead to a regression because other arithmetic doesn't fuse with it anymore. I'll address that problem in a followup. llvm-svn: 147254
* Move this test from date-name to feature-name, and port it to FileCheck.Nick Lewycky2011-12-231-2/+14
| | | | llvm-svn: 147223
* Reinstate r146578; it doesn't appear to be the cause of some recent execution-Chad Rosier2011-12-223-0/+313
| | | | | | | | | | time regressions. In general, it is beneficial to compile-time. Original commit message: Fix for bug #11429: Wrong behaviour for switches. Small improvement for code size heuristics. llvm-svn: 147175
* Give string constants generated by IRBuilder private linkage.Benjamin Kramer2011-12-221-1/+1
| | | | | | Fixes PR11640. llvm-svn: 147144
* Speculatively revert r146578 to determine if it is the cause of a number ofChad Rosier2011-12-223-313/+0
| | | | | | | | | | | performance regressions (both execution-time and compile-time) on our nightly testers. Original commit message: Fix for bug #11429: Wrong behaviour for switches. Small improvement for code size heuristics. llvm-svn: 147131
* Make some intrinsics safe to speculatively execute.Nick Lewycky2011-12-211-3/+28
| | | | llvm-svn: 147036
* Unit test for r146950: LSR postinc expansion, PR11571.Andrew Trick2011-12-201-0/+39
| | | | llvm-svn: 146951
* Allow inlining of functions with returns_twice calls, if they have theJoerg Sonnenberger2011-12-181-0/+41
| | | | | | attribute themselve. llvm-svn: 146851
* Revert r146822 at Pete Cooper's request as it broke clang self hosting.Kevin Enderby2011-12-171-152/+0
| | | | | | Hope I did this correctly :) llvm-svn: 146834
* SimplifyCFG now predicts some conditional branches to true or false ↵Pete Cooper2011-12-171-0/+152
| | | | | | | | | | | | | depending on previous branch on same comparison operands. For example, if (a == b) { if (a > b) // this is false Fixes some of the issues on <rdar://problem/10554090> llvm-svn: 146822
* Added InstCombine for "select cond, ~cond, x" type patternsPete Cooper2011-12-151-0/+20
| | | | | | These can be reduced to "~cond & x" or "~cond | x" llvm-svn: 146624
* Make loop preheader insertion in LoopSimplify handle the case where the loop ↵Eli Friedman2011-12-151-0/+45
| | | | | | header is a landing pad correctly (by splitting the landingpad out of the loop header). Make some adjustments to the rest of LoopSimplify to make it clear that the rest of LoopSimplify isn't making bad assumptions about the presence of landing pads. PR11575. llvm-svn: 146621
* Move Instruction::isSafeToSpeculativelyExecute out of VMCore andDan Gohman2011-12-141-0/+167
| | | | | | | | | into Analysis as a standalone function, since there's no need for it to be in VMCore. Also, update it to use isKnownNonZero and other goodies available in Analysis, making it more precise, enabling more aggressive optimization. llvm-svn: 146610
* LSR: Fold redundant bitcasts on-the-fly.Andrew Trick2011-12-141-4/+4
| | | | llvm-svn: 146597
* Fix for bug #11429: Wrong behaviour for switches. Small improvement for code ↵Stepan Dyatkovskiy2011-12-143-0/+313
| | | | | | size heuristics. llvm-svn: 146578
* It turns out that clang does use pointer-to-function types toDan Gohman2011-12-142-1/+34
| | | | | | point to ARC-managed pointers sometimes. This fixes rdar://10551239. llvm-svn: 146577
* Only replace fwrite with fputc, if the return value is unused.Joerg Sonnenberger2011-12-121-0/+13
| | | | llvm-svn: 146411
* Manually upgrade the test suite to specify the flag to cttz and ctlz.Chandler Carruth2011-12-125-20/+20
| | | | | | | | | | | | | | | | | | | | | | | I followed three heuristics for deciding whether to set 'true' or 'false': - Everything target independent got 'true' as that is the expected common output of the GCC builtins. - If the target arch only has one way of implementing this operation, set the flag in the way that exercises the most of codegen. For most architectures this is also the likely path from a GCC builtin, with 'true' being set. It will (eventually) require lowering away that difference, and then lowering to the architecture's operation. - Otherwise, set the flag differently dependending on which target operation should be tested. Let me know if anyone has any issue with this pattern or would like specific tests of another form. This should allow the x86 codegen to just iteratively improve as I teach the backend how to differentiate between the two forms, and everything else should remain exactly the same. llvm-svn: 146370
* Add -unroll-runtime for unrolling loops with run-time trip counts.Andrew Trick2011-12-094-0/+214
| | | | | | | | | | | | | Patch by Brendon Cahoon! This extends the existing LoopUnroll and LoopUnrollPass. Brendon measured no regressions in the llvm test suite with -unroll-runtime enabled. This implementation works by using the existing loop unrolling code to unroll the loop by a power-of-two (default 8). It generates an if-then-else sequence of code prior to the loop to execute the extra iterations before entering the unrolled loop. llvm-svn: 146245
* Fix infinite loop in DSE when deleting a free in a reachable loop that's alsoNick Lewycky2011-12-081-0/+10
| | | | | | trivially infinite. llvm-svn: 146197
* LSR: prune undesirable formulae early.Andrew Trick2011-12-061-0/+96
| | | | | | | | | It's always good to prune early, but formulae that are unsatisfactory in their own right need to be removed before running any other pruning heuristics. We easily avoid generating such formulae, but we need them as an intermediate basis for forming other good formulae. llvm-svn: 145906
* Probably not a good idea to convert a single vector load into a memcpy. WeChad Rosier2011-12-061-0/+12
| | | | | | | | don't do this now, but add a test case to prevent this from happening in the future. Additional test for rdar://9892684 llvm-svn: 145879
* Make the MemCpyOptimizer a bit more aggressive. I can't think of a scenerioChad Rosier2011-12-051-1/+17
| | | | | | | | where this would be bad as the backend shouldn't have a problem inlining small memcpys. rdar://10510150 llvm-svn: 145865
* Add support for vectors of pointers.Nadav Rotem2011-12-052-0/+45
| | | | llvm-svn: 145801
* Fixed deadstoreelimination bug where negative indices were incorrectly ↵Pete Cooper2011-12-031-0/+17
| | | | | | | | | | causing the optimisation to occur Turns out long long + unsigned long long is unsigned. Doh! Fixes http://llvm.org/bugs/show_bug.cgi?id=11455 llvm-svn: 145731
* Add support for constant folding the pow intrinsic.Chad Rosier2011-12-031-0/+9
| | | | | | rdar://10514247 llvm-svn: 145730
* Prevent library calls from being folded if -fno-builtin has been specified.Chad Rosier2011-12-011-0/+79
| | | | | | rdar://10500969 llvm-svn: 145639
* Improved fix for abs(val) != 0 to check other similar case. Also fixed ↵Pete Cooper2011-12-011-2/+12
| | | | | | style issues and confusing comment llvm-svn: 145618
* Removed use of grep from test and moved it to be with other icmp testsPete Cooper2011-12-012-10/+11
| | | | llvm-svn: 145570
* Added instcombine pattern to spot comparing -val or val against 0.Pete Cooper2011-12-011-0/+10
| | | | | | | | (val != 0) == (-val != 0) so "abs(val) != 0" becomes "val != 0" Fixes <rdar://problem/10482509> llvm-svn: 145563
* Better test case found in duplicate PR10570.Andrew Trick2011-11-301-43/+23
| | | | llvm-svn: 145484
* LSR: handle the expansion of phi operands that use postinc forms of the IV.Andrew Trick2011-11-301-0/+56
| | | | | | Fixes PR11431: SCEVExpander::expandAddRecExprLiterally(const llvm::SCEVAddRecExpr*): Assertion `(!isa<Instruction>(Result) || SE.DT->dominates(cast<Instruction>(Result), Builder.GetInsertPoint())) && "postinc expansion does not dominate use"' failed. llvm-svn: 145482
* Add support for sqrt, sqrtl, and sqrtf in TargetLibraryInfo. Disable Chad Rosier2011-11-291-0/+17
| | | | | | | | (fptrunc (sqrt (fpext x))) -> (sqrtf x) transformation if -fno-builtin is specified. rdar://10466410 llvm-svn: 145460
* Fix a theoretical problem (not seen in the wild): if different instances of aDuncan Sands2011-11-291-3/+10
| | | | | | | | | | | | | | | weak variable are compiled by different compilers, such as GCC and LLVM, while LLVM may increase the alignment to the preferred alignment there is no reason to think that GCC will use anything more than the ABI alignment. Since it is the GCC version that might end up in the final program (as the linkage is weak), it is wrong to increase the alignment of loads from the global up to the preferred alignment as the alignment might only be the ABI alignment. Increasing alignment up to the ABI alignment might be OK, but I'm not totally convinced that it is. It seems better to just leave the alignment of weak globals alone. llvm-svn: 145413
* Reenable this IndVars unit test.Andrew Trick2011-11-291-4/+1
| | | | | | SCEV can't optimize undef in all cases, which is a separate issue from this test case. llvm-svn: 145343
* Add a missing safety check to ProcessUGT_ADDCST_ADD. Fixes PR11438.Eli Friedman2011-11-281-0/+22
| | | | llvm-svn: 145316
OpenPOWER on IntegriCloud