summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* This implements a more optimal algorithm for selecting a base constant inSjoerd Meijer2016-07-141-7/+98
| | | | | | | | | | | | | | constant hoisting. It not only takes into account the number of uses and the cost of expressions in which constants appear, but now also the resulting integer range of the offsets. Thus, the algorithm maximizes the number of uses within an integer range that will enable more efficient code generation. On ARM, for example, this will enable code size optimisations because less negative offsets will be created. Negative offsets/immediates are not supported by Thumb1 thus preventing more compact instruction encoding. Differential Revision: http://reviews.llvm.org/D21183 llvm-svn: 275382
* [InstCombine] Masked loads with undef masks can fold to normal loadsDavid Majnemer2016-07-141-6/+19
| | | | | | | | We were able to fold masked loads with an all-ones mask to a normal load. However, we couldn't turn a masked load with a mask with mixed ones and undefs into a normal load. llvm-svn: 275380
* [SCCP] Pass a Value * instead of templating this function. NFC.Davide Italiano2016-07-141-9/+8
| | | | | | Thanks to Eli for the suggestion! llvm-svn: 275366
* [IPSCCP] Constant fold struct argument/instructions when all the lattice ↵Davide Italiano2016-07-141-10/+3
| | | | | | | | | | | values are constant. This now should also work with the interprocedural variant of the pass. Slightly easier now that the yak is shaved. Differential Revision: http://reviews.llvm.org/D22329 llvm-svn: 275363
* [Scalarizer] PR28108: Skip over nullptr rather than crashing on it.Mehdi Amini2016-07-141-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In Scalarizer::gather we see if we already have a scattered form of Op, and in that case use the new form. In the particular case of PR28108, the found ValueVector SV has size 2, where the first Value is nullptr, and the second is indeed a proper Value. The nullptr then caused an assert to blow when we tried to do cast<Instruction>(SV[I]). With this patch we check SV[I] before doing the cast, and if it's nullptr we just skip over it. I don't know the Scalarizer well enough to know if this is the best fix or if something should be done else where to prevent the nullptr from being in the ValueVector at all, but at least this avoids the crash and looking at the test case output it looks reasonable. Reviewers: hfinkel, frasercrmck, wala, mehdi_amini Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D21518 llvm-svn: 275359
* [SCCP] Generalize tryToReplaceInstWithConstant to work also with arguments.Davide Italiano2016-07-141-22/+18
| | | | llvm-svn: 275357
* [JumpThreading] Delete commented out debug code; NFCSanjoy Das2016-07-131-3/+0
| | | | llvm-svn: 275346
* Move a transform from InstCombine to InstSimplify.David Majnemer2016-07-131-4/+0
| | | | | | | This transform doesn't require any new instructions, it can safely live in InstSimplify. llvm-svn: 275344
* [SCCP] Have the logic for replacing insts with constant in a single place.Davide Italiano2016-07-131-53/+50
| | | | | | | | | The code was pretty much copy-pasted between SCCP and IPSCCP. The situation became clearly worse after I introduced the support for folding structs in SCCP. This commit is NFC as we currently (still) skip the replacement step in IPSCCP, but I'll change this soon. llvm-svn: 275339
* Extended LoadStoreVectorizer to vectorize subchains.Alina Sbirlea2016-07-131-64/+118
| | | | | | | | | | | | | | Summary: LSV used to abort vectorizing a chain for interleaved load/store accesses that alias. Allow a valid prefix of the chain to be vectorized, mark just the prefix and retry vectorizing the remaining chain. Reviewers: llvm-commits, jlebar, arsenm Subscribers: mzolotukhin Differential Revision: http://reviews.llvm.org/D22119 llvm-svn: 275317
* [SCCP] Factor out common code.Davide Italiano2016-07-131-8/+9
| | | | llvm-svn: 275308
* [SCCP] Use early return. NFCI.Davide Italiano2016-07-131-5/+5
| | | | llvm-svn: 275307
* Reverting r275284 due to platform-specific test failuresAndrew Kaylor2016-07-131-1/+0
| | | | llvm-svn: 275304
* [InstCombine] extend vector select matching for non-splat constantsSanjay Patel2016-07-131-3/+40
| | | | | | | | | | | | | | | In D21740, we discussed trying to make this a more general matcher. However, I didn't see a clean way to handle the regular m_Not cases and these non-splat vector patterns, so I've opted for the direct approach here. If there are other potential uses of areInverseVectorBitmasks(), we could move that helper function to a higher level. There is an open question as to which is of these forms should be considered the canonical IR: %sel = select <4 x i1> <i1 true, i1 false, i1 false, i1 true>, <4 x i32> %a, <4 x i32> %b %shuf = shufflevector <4 x i32> %a, <4 x i32> %b, <4 x i32> <i32 0, i32 5, i32 6, i32 3> Differential Revision: http://reviews.llvm.org/D22114 llvm-svn: 275289
* Fix for Bug 26903, adds support to inline __builtin_mempcpyAndrew Kaylor2016-07-131-0/+1
| | | | | | | | Patch by Sunita Marathe Differential Revision: http://reviews.llvm.org/D21920 llvm-svn: 275284
* [LoopVectorize] Further cleanupsDavid Majnemer2016-07-131-4/+2
| | | | | | No functional change is intended, just a minor cleanup. llvm-svn: 275243
* [LV] Do not invalidate use-lists we're iterating over.Michael Kuperstein2016-07-121-14/+15
| | | | | | Should make sanitizers happier. llvm-svn: 275230
* New pass manager for LICM.Dehao Chen2016-07-122-66/+100
| | | | | | | | | | | | Summary: Port LICM to the new pass manager. Reviewers: davidxl, silvas Subscribers: krasin, vitalybuka, silvas, davide, sanjoy, llvm-commits, mehdi_amini Differential Revision: http://reviews.llvm.org/D21772 llvm-svn: 275222
* Remove unused variable to fix bot failure from r275216Teresa Johnson2016-07-121-2/+1
| | | | | | | Remove unused variable added in r275216. Should fix bot failure: http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/24665 llvm-svn: 275219
* [LV] Remove wrong assumption about LCSSAMichael Kuperstein2016-07-121-5/+0
| | | | | | | | | The LCSSA pass itself will not generate several redundant PHI nodes in a single exit block. However, such redundant PHI nodes don't violate LCSSA form, and may be introduced by passes that preserve LCSSA, and/or preserved by the LCSSA pass itself. So, assuming a single PHI node per exit block is not safe. llvm-svn: 275217
* Refactor indirect call promotion profitability analysis (NFC)Teresa Johnson2016-07-123-105/+22
| | | | | | | | | | | | | | | Summary: Refactored the profitability analysis out of the IC promotion pass and into lib/Analysis so that it can be accessed by the summary index builder in a follow-on patch to enable IC promotion in ThinLTO (D21932). Reviewers: davidxl, xur Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D22182 llvm-svn: 275216
* [SCCP] Constant fold structs if all the lattice value are constant.Davide Italiano2016-07-121-9/+35
| | | | | | Differential Revision: http://reviews.llvm.org/D22269 llvm-svn: 275208
* [LoopVectorize] Assorted cleanupsDavid Majnemer2016-07-121-223/+184
| | | | | | | | | Use range-based for loops instead of doing everything manually. Use auto when appropriate. No functional change is intended. llvm-svn: 275205
* [PM] Port LoopIdiomRecognize Pass to new PMDehao Chen2016-07-122-37/+81
| | | | | | | | | | | | Summary: Port LoopIdiomRecognize Pass to new PM Reviewers: davidxl Subscribers: davide, sanjoy, mzolotukhin, llvm-commits Differential Revision: http://reviews.llvm.org/D22250 llvm-svn: 275202
* Revert "New pass manager for LICM."Vitaly Buka2016-07-122-99/+65
| | | | | | | | | | Summary: This reverts commit r275118. Subscribers: sanjoy, mehdi_amini Differential Revision: http://reviews.llvm.org/D22259 llvm-svn: 275156
* Print remarks from WholeProgramDevirt pass for each call site.Ivan Krasin2016-07-121-0/+10
| | | | | | | | | | | | | Summary: It's useful to have some visibility about which call sites are devirtualized, especially for debug purposes. Another use case is a regression test on the application side (like, Chromium). Reviewers: pcc Differential Revision: http://reviews.llvm.org/D22252 llvm-svn: 275145
* New pass manager for LICM.Dehao Chen2016-07-112-65/+99
| | | | | | | | | | | | Summary: Port LICM to the new pass manager. Reviewers: davidxl, silvas Subscribers: silvas, davide, sanjoy, llvm-commits, mehdi_amini Differential Revision: http://reviews.llvm.org/D21772 llvm-svn: 275118
* Correct ordering of loads/stores.Alina Sbirlea2016-07-111-15/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Aiming to correct the ordering of loads/stores. This patch changes the insert point for loads to the position of the first load. It updates the ordering method for loads to insert before, rather than after. Before this patch the following sequence: "load a[1], store a[1], store a[0], load a[2]" Would incorrectly vectorize to "store a[0,1], load a[1,2]". The correctness check was assuming the insertion point for loads is at the position of the first load, when in practice it was at the last load. An alternative fix would have been to invert the correctness check. The current fix changes insert position but also requires reordering of instructions before the vectorized load. Updated testcases to reflect the changes. Reviewers: tstellarAMD, llvm-commits, jlebar, arsenm Subscribers: mzolotukhin Differential Revision: http://reviews.llvm.org/D22071 llvm-svn: 275117
* Add TLI.allowsMisalignedMemoryAccesses to LoadStoreVectorizerAlina Sbirlea2016-07-111-24/+34
| | | | | | | | | | | | | Summary: Extend TTI to access TLI.allowsMisalignedMemoryAccesses(). Check condition when vectorizing load and store chains. Add additional parameters: AddressSpace, Alignment, Fast. Reviewers: llvm-commits, jlebar Subscribers: arsenm, mzolotukhin Differential Revision: http://reviews.llvm.org/D21935 llvm-svn: 275100
* [SCCP] Try to follow the DRY principle, use `OpSt`.Davide Italiano2016-07-111-3/+2
| | | | | | Thanks to Eli Friedman for pointing out in his post-commit review! llvm-svn: 275084
* [SLSR] Call getPointerSizeInBits with the correct address space.Jingyue Wu2016-07-111-2/+2
| | | | llvm-svn: 275083
* [PM/IPO] Port LowerTypeTests to the new PassManager.Davide Italiano2016-07-111-17/+28
| | | | | | | | There's a little bit of churn in this patch because the initialization mechanism is now shared between the old and the new PM. Other than that, it's just a pretty mechanical translation. llvm-svn: 275082
* [LowerTypeTests] Don't rely on doInitialization().Davide Italiano2016-07-111-23/+16
| | | | | | | | | In preparation for porting this pass to the new PM (which has no doInitialization()). Differential Revision: http://reviews.llvm.org/D22223 llvm-svn: 275074
* Implement callsite-hotness based inline cost for Sample-based PGODehao Chen2016-07-111-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: For sample-based PGO, using BFI to calculate callsite count is sometime not accurate. This is because with sampling based approach, if a callsite resides in a hot loop deeply nested in a bunch of cold branches, the callsite's BFI frequency would be inaccurately calculated due to lack of samples in the cold branch. E.g. if (A1 && A2 && A3 && ..... && A10) { for (i=0; i < 100000000; i++) { callsite(); } } Assume that A1 to A100 are all 100% taken, and callsite has 1000 samples and thus is considerred hot. Because the loop's trip count is huge, it's normal that all branches outside the loop has no sample at all. As a result, we can only use static branch probability to derive the the frequency of the loop header. Assuming that static heuristic thinks each branch is 50% taken, then the count calculated from BFI will be 1/(2^10) of the actual value. In order to get more accurate callsite count, we directly annotate the weight on the call instruction, and directly use it when checking callsite hotness. Note that this mechanism can also be shared by instrumentation based callsite hotness analysis. The side benefit is that it breaks the dependency from Inliner to BFI as call count is embedded in the IR. Reviewers: davidxl, eraman, dnovillo Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D22118 llvm-svn: 275073
* Tune the weight propagation algorithm for sample profile.Dehao Chen2016-07-111-12/+26
| | | | | | | | | | | | Summary: Handle the case when there is only one incoming/outgoing edge for a visited basic block: use the block weight to adjust edge weight even when the edge has been visited before. This can help reduce inaccuracies introduced by incorrect basic block profile, as shown in the updated unittest. Reviewers: davidxl, dnovillo Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D22180 llvm-svn: 275072
* [Sink] Don't move calls to readonly functions across storesNicolai Haehnle2016-07-111-2/+6
| | | | | | | | | | | | Summary: Reviewers: hfinkel, majnemer, tstellarAMD, sunfish Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D17279 llvm-svn: 275066
* Revert r275027 - Let FuncAttrs infer the 'returned' argument attributeHal Finkel2016-07-111-50/+0
| | | | | | Reverting r275027 and r275033. These seem to cause miscompiles on the AArch64 buildbot. llvm-svn: 275042
* Don't use a SmallSet for returned attribute inferenceHal Finkel2016-07-111-11/+19
| | | | | | | Suggested post-commit by David Majnemer on IRC (following-up on a pre-commit review comment). llvm-svn: 275033
* Let FuncAttrs infer the 'returned' argument attributeHal Finkel2016-07-101-0/+42
| | | | | | | | | | A function can have one argument with the 'returned' attribute, indicating that the associated argument is always the return value of the function. Add FuncAttrs inference logic. Differential Revision: http://reviews.llvm.org/D22202 llvm-svn: 275027
* Give helper classes/functions internal linkage. NFC.Benjamin Kramer2016-07-104-0/+8
| | | | llvm-svn: 275014
* [SCCP] Rename undefined -> unknown.Davide Italiano2016-07-101-40/+40
| | | | | | | | | | In the solver, isUndefined() does really mean "we don't know the value yet" rather than "this is an UndefinedValue". Discussed with Eli Friedman. Differential Revision: http://reviews.llvm.org/D22192 llvm-svn: 275004
* [PM] Port LoopVectorize to the new PM.Sean Silva2016-07-091-338/+371
| | | | llvm-svn: 275000
* [SCCP] Remove wrong and misleading vector handling code.Davide Italiano2016-07-091-53/+0
| | | | | | | | | This code was already commented out and it made some weird assumptions, e.g. using isUndefined() as "this value is UndefValue" instead of "we haven't computed this value is yet". Thanks to Eli Friedman for pointing out where I was wrong (and where this code was wrong). llvm-svn: 274995
* [SLSR] Fix crash on handling 128-bit integers.Jingyue Wu2016-07-091-7/+20
| | | | | | | | | ConstantInt::getSExtValue may fail on >64-bit integers. Add checks to call getSExtValue only on narrow integers. As a minor aside, simplify slsr-gep.ll to remove unnecessary load instructions. llvm-svn: 274982
* [ArgPromote] Use function_ref and for-range loops.Benjamin Kramer2016-07-091-13/+10
| | | | | | No functionality change intended. llvm-svn: 274973
* [LoopSimplify] Remove a comment which is unlikely to age well.Davide Italiano2016-07-091-4/+0
| | | | | | | Chandler pointed out in his review but I forgot to remove before committing, my bad. llvm-svn: 274963
* [PM] Port CrossDSOCFI to the new pass manager.Davide Italiano2016-07-091-1/+10
| | | | llvm-svn: 274962
* [PM] Fix a think-o. mv {Scalar,Vectorize}/SLPVectorize.hSean Silva2016-07-091-1/+1
| | | | llvm-svn: 274960
* [PM] Port LoopSimplify to the new pass manager.Davide Italiano2016-07-092-0/+32
| | | | | | | | | While here move simplifyLoop() function to the new header, as suggested by Chandler in the review. Differential Revision: http://reviews.llvm.org/D21404 llvm-svn: 274959
* Add 'thinlto_src_module' md with asserts or -enable-import-metadataPiotr Padlewski2016-07-081-6/+19
| | | | | | | | | | | | | | | | Summary: This way the metadata will be only generated when asserts enabled, or when -enable-import-metadata specified FIXED missing colon on requires. Reviewers: tejohnson, eraman, mehdi_amini Subscribers: mehdi_amini, llvm-commits Differential Revision: http://reviews.llvm.org/D22167 llvm-svn: 274947
OpenPOWER on IntegriCloud