aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar
AgeCommit message (Collapse)Author
2017-11-07Make DIExpression::createFragmentExpression() return an Optional.Adrian Prantl
We can't safely split arithmetic into multiple fragments because we can't express carry-over between fragments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317534 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-06Fix comment /NFCXinliang David Li
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317514 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-06[IR] redefine 'UnsafeAlgebra' / 'reassoc' fast-math-flags and add 'trans' ↵Sanjay Patel
fast-math-flag As discussed on llvm-dev: http://lists.llvm.org/pipermail/llvm-dev/2016-November/107104.html and again more recently: http://lists.llvm.org/pipermail/llvm-dev/2017-October/118118.html ...this is a step in cleaning up our fast-math-flags implementation in IR to better match the capabilities of both clang's user-visible flags and the backend's flags for SDNode. As proposed in the above threads, we're replacing the 'UnsafeAlgebra' bit (which had the 'umbrella' meaning that all flags are set) with a new bit that only applies to algebraic reassociation - 'AllowReassoc'. We're also adding a bit to allow approximations for library functions called 'ApproxFunc' (this was initially proposed as 'libm' or similar). ...and we're out of bits. 7 bits ought to be enough for anyone, right? :) FWIW, I did look at getting this out of SubclassOptionalData via SubclassData (spacious 16-bits), but that's apparently already used for other purposes. Also, I don't think we can just add a field to FPMathOperator because Operator is not intended to be instantiated. We'll defer movement of FMF to another day. We keep the 'fast' keyword. I thought about removing that, but seeing IR like this: %f.fast = fadd reassoc nnan ninf nsz arcp contract afn float %op1, %op2 ...made me think we want to keep the shortcut synonym. Finally, this change is binary incompatible with existing IR as seen in the compatibility tests. This statement: "Newer releases can ignore features from older releases, but they cannot miscompile them. For example, if nsw is ever replaced with something else, dropping it would be a valid way to upgrade the IR." ( http://llvm.org/docs/DeveloperPolicy.html#ir-backwards-compatibility ) ...provides the flexibility we want to make this change without requiring a new IR version. Ie, we're not loosening the FP strictness of existing IR. At worst, we will fail to optimize some previously 'fast' code because it's no longer recognized as 'fast'. This should get fixed as we audit/squash all of the uses of 'isFast()'. Note: an inter-dependent clang commit to use the new API name should closely follow commit. Differential Revision: https://reviews.llvm.org/D39304 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317488 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-04[CallSiteSplitting] clang-format my last commit. NFCI.Davide Italiano
Thanks to Rui for pointing out. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317393 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03[CallSiteSplitting] Silence GCC's -Wparentheses. NFCI.Davide Italiano
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317385 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03Recommit r317351 : Add CallSiteSplitting passJun Bum Lim
This recommit r317351 after fixing a buildbot failure. Original commit message: Summary: This change add a pass which tries to split a call-site to pass more constrained arguments if its argument is predicated in the control flow so that we can expose better context to the later passes (e.g, inliner, jump threading, or IPA-CP based function cloning, etc.). As of now we support two cases : 1) If a call site is dominated by an OR condition and if any of its arguments are predicated on this OR condition, try to split the condition with more constrained arguments. For example, in the code below, we try to split the call site since we can predicate the argument (ptr) based on the OR condition. Split from : if (!ptr || c) callee(ptr); to : if (!ptr) callee(null ptr) // set the known constant value else if (c) callee(nonnull ptr) // set non-null attribute in the argument 2) We can also split a call-site based on constant incoming values of a PHI For example, from : BB0: %c = icmp eq i32 %i1, %i2 br i1 %c, label %BB2, label %BB1 BB1: br label %BB2 BB2: %p = phi i32 [ 0, %BB0 ], [ 1, %BB1 ] call void @bar(i32 %p) to BB0: %c = icmp eq i32 %i1, %i2 br i1 %c, label %BB2-split0, label %BB1 BB1: br label %BB2-split1 BB2-split0: call void @bar(i32 0) br label %BB2 BB2-split1: call void @bar(i32 1) br label %BB2 BB2: %p = phi i32 [ 0, %BB2-split0 ], [ 1, %BB2-split1 ] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317362 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03Revert "Add CallSiteSplitting pass"Jun Bum Lim
Revert due to Buildbot failure. This reverts commit r317351. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317353 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03Add CallSiteSplitting passJun Bum Lim
Summary: This change add a pass which tries to split a call-site to pass more constrained arguments if its argument is predicated in the control flow so that we can expose better context to the later passes (e.g, inliner, jump threading, or IPA-CP based function cloning, etc.). As of now we support two cases : 1) If a call site is dominated by an OR condition and if any of its arguments are predicated on this OR condition, try to split the condition with more constrained arguments. For example, in the code below, we try to split the call site since we can predicate the argument (ptr) based on the OR condition. Split from : if (!ptr || c) callee(ptr); to : if (!ptr) callee(null ptr) // set the known constant value else if (c) callee(nonnull ptr) // set non-null attribute in the argument 2) We can also split a call-site based on constant incoming values of a PHI For example, from : BB0: %c = icmp eq i32 %i1, %i2 br i1 %c, label %BB2, label %BB1 BB1: br label %BB2 BB2: %p = phi i32 [ 0, %BB0 ], [ 1, %BB1 ] call void @bar(i32 %p) to BB0: %c = icmp eq i32 %i1, %i2 br i1 %c, label %BB2-split0, label %BB1 BB1: br label %BB2-split1 BB2-split0: call void @bar(i32 0) br label %BB2 BB2-split1: call void @bar(i32 1) br label %BB2 BB2: %p = phi i32 [ 0, %BB2-split0 ], [ 1, %BB2-split1 ] Reviewers: davidxl, huntergr, chandlerc, mcrosier, eraman, davide Reviewed By: davidxl Subscribers: sdesmalen, ashutosh.nema, fhahn, mssimpso, aemerson, mgorny, mehdi_amini, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D39137 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317351 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03The patch fixes PR35131Evgeny Stupachenko
Summary: Fix a misprint which led to false CTLZ recognition. Reviewers: craig.topper Differential Revision: https://reviews.llvm.org/D39585 From: Evgeny Stupachenko <evstupac@gmail.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317348 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03[LICM] sink through non-trivially replicable PHIJun Bum Lim
Summary: The current LICM allows sinking an instruction only when it is exposed to exit blocks through a trivially replacable PHI of which all incoming values are the same instruction. This change enhance LICM to sink a sinkable instruction through non-trivially replacable PHIs by spliting predecessors of loop exits. Reviewers: hfinkel, majnemer, davidxl, bmakam, mcrosier, danielcdh, efriedma, jtony Reviewed By: efriedma Subscribers: nemanjai, dberlin, llvm-commits Differential Revision: https://reviews.llvm.org/D37163 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317335 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03[LoopPredication] NFC: Refactored code to separate out functions being reusedAnna Thomas
Summary: Refactored the code to separate out common functions that are being reused. This is to reduce the changes for changes coming up wrt loop predication with reverse loops. This refactoring is what we have in our downstream code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317324 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03[ADCE] Use MapVector for BlockInfo to make iteration order deterministicMikael Holmen
Summary: Also added a reserve() method to MapVector since we want to use that from ADCE. DenseMap does not provide deterministic iteration order so with that we will handle the members of BlockInfo in random order, eventually leading to random order of the blocks in the predecessor lists. Without this change, I get the same predecessor order in about 90% of the time when I compile a certain reproducer and in 10% I get a different one. No idea how to make a proper test case for this. Reviewers: kuhar, david2050 Reviewed By: kuhar Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39593 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317323 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03[LSR] Clarify a comment. NFC.Vedant Kumar
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317295 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-02IndVarSimplify: preserve debug information attached to widened PHI nodes.Adrian Prantl
This fixes PR35015. https://bugs.llvm.org/show_bug.cgi?id=35015 Differential Revision: https://reviews.llvm.org/D39345 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317282 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-02[LoopPredication] Enable predication when latchCheckIV is wider than rangeCheckAnna Thomas
Summary: This patch allows us to predicate range checks that have a type narrower than the latch check type. We leverage SCEV analysis to identify a truncate for the latchLimit and latchStart. There is also safety checks in place which requires the start and limit to be known at compile time. We require this to make sure that the SCEV truncate expr for the IV corresponding to the latch does not cause us to lose information about the IV range. Added tests show the loop predication over range checks that are of various types and are narrower than the latch type. This enhancement has been in our downstream tree for a while. Reviewers: apilipenko, sanjoy, mkazantsev Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39500 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317269 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-02Strip off invariant.start because memory locations arent invariantAnna Thomas
The original change was reverted in rL317217 because of the failure in the RS4GC testcase. I couldn't reproduce the failure on my local machine (macbook) but could reproduce it on a linux box. The failure was around removing the uses of invariant.start. The fix here is to just RAUW undef (which was the first implementation in D39388). This is perfectly valid IR as discussed in the review. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317225 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-02Revert "[RS4GC] Strip off invariant.start because memory locations arent ↵Anna Thomas
invariant" This reverts commit r317215, investigating the test failure. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317217 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-02[RS4GC] Strip off invariant.start because memory locations arent invariantAnna Thomas
Summary: Invariant.start on memory locations has the property that the memory location is unchanging. However, this is not true in the face of rewriting statepoints for GC. Teach RS4GC about removing invariant.start so that optimizations after RS4GC does not incorrect sink a load from the memory location past a statepoint. Added test showcasing the issue. Reviewers: reames, apilipenko, dneilson Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39388 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317215 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-02Revert "[ExpandMemCmp] Split ExpandMemCmp from CodeGen into its own pass."Clement Courbet
undefined reference to `llvm::TargetPassConfig::ID' on clang-ppc64le-linux-multistage This reverts commit eea333c33fa73ad225ef28607795984829f65688. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317213 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-02[ExpandMemCmp] Split ExpandMemCmp from CodeGen into its own pass.Clement Courbet
Summary: This is mostly a noop (most of the test diffs are renamed blocks). There are a few temporary register renames (eax<->ecx) and a few blocks are shuffled around. See the discussion in PR33325 for more details. Reviewers: spatel Subscribers: mgorny Differential Revision: https://reviews.llvm.org/D39456 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317211 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-01loop-rotate: avoid duplicating dbg.value intrinsics in the entry block.Adrian Prantl
This fixes the second half of PR35113. This reapplies r317106 without modifications. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317121 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-01Revert r317106 to facilitate reverting r317105.Adrian Prantl
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317109 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-01loop-rotate: avoid duplicating dbg.value intrinsics in the entry block.Adrian Prantl
This fixes the second half of PR35113. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317106 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-01Revert rL311205 "[IRCE] Fix buggy behavior in Clamp"Max Kazantsev
This patch reverts rL311205 that was initially a wrong fix. The real problem was in intersection of signed and unsigned ranges (see rL316552), and the patch being reverted masked the problem instead of fixing it. By now, the test against which rL311205 was made works OK even without this code. This revert patch also contains a test case that demonstrates incorrect behavior caused by rL311205: it is caused by incorrect choise of signed max instead of unsigned. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317088 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-31loop-rotate: simplify code by using llvm::findDbgValues(). (NFC)Adrian Prantl
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317037 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-31[IRCE][NFC] Rename fields of InductiveRangeCheckMax Kazantsev
Rename `Offset`, `Scale`, `Length` into `Begin`, `Step`, `End` respectively to make naming of similar entities for Ranges and Range Checks more consistent. Differential Revision: https://reviews.llvm.org/D39414 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316979 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-31[NFC] Get rid of variables used in assert onlyMax Kazantsev
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316977 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-31Reapply "[GVN] Prevent LoadPRE from hoisting across instructions that don't ↵Max Kazantsev
pass control flow to successors" This patch fixes the miscompile that happens when PRE hoists loads across guards and other instructions that don't always pass control flow to their successors. PRE is now prohibited to hoist across such instructions because there is no guarantee that the load standing after such instruction is still valid before such instruction. For example, a load from under a guard may be invalid before the guard in the following case: int array[LEN]; ... guard(0 <= index && index < LEN); use(array[index]); Differential Revision: https://reviews.llvm.org/D37460 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316975 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-30InferAddressSpaces: Fix bug about replacing addrspacecastYaxun Liu
InferAddressSpaces assumes the pointee type of addrspacecast is the same as the operand, which is not always true and causes invalid IR. This bug cause build failure in HCC. This patch fixes that. Differential Revision: https://reviews.llvm.org/D39432 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316957 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-30[NewGVN] Stop assuming PHI args ordering when looking at phi-of-ops.Davide Italiano
It's not guaranteed. There's a bug open to sort them in predecessor order, but it won't happen anytime soon. In the meanwhile, passes will have to do an O(#preds) scan. Such is life. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316953 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-30[GVNHoist] Fix non-deterministic sort order of PHIs for identical instructionsMandeep Singh Grang
Summary: This fixes failure in Transforms/GVNHoist/hoist.ll uncovered by D39245. Reviewers: hiraditya, spop, dberlin Reviewed By: dberlin Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39410 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316949 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-30[CodeGen][ExpandMemcmp] Allow memcmp to expand to vector loads (2).Clement Courbet
- Targets that want to support memcmp expansions now return the list of supported load sizes. - Expansion codegen does not assume that all power-of-two load sizes smaller than the max load size are valid. For examples, this is not the case for x86(32bit)+sse2. Fixes PR34887. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316905 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-30Recommit r315288: [SCCP] Propagate integer range info for parameters in IPSCCP.Florian Hahn
This version of the patch includes a fix addressing a stage2 LTO buildbot failure and addressed some additional nits. Original commit message: This updates the SCCP solver to use of the ValueElement lattice for parameters, which provides integer range information. The range information is used to remove unneeded icmp instructions. For the following function, f() can be optimized to ret i32 2 with this change source_filename = "sccp.c" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" ; Function Attrs: norecurse nounwind readnone uwtable define i32 @main() local_unnamed_addr #0 { entry: %call = tail call fastcc i32 @f(i32 1) %call1 = tail call fastcc i32 @f(i32 47) %add3 = add nsw i32 %call, %call1 ret i32 %add3 } ; Function Attrs: noinline norecurse nounwind readnone uwtable define internal fastcc i32 @f(i32 %x) unnamed_addr #1 { entry: %c1 = icmp sle i32 %x, 100 %cmp = icmp sgt i32 %x, 300 %. = select i1 %cmp, i32 1, i32 2 ret i32 %. } attributes #1 = { noinline } Reviewers: davide, sanjoy, efriedma, dberlin Reviewed By: davide, dberlin Subscribers: mcrosier, gberry, mssimpso, dberlin, llvm-commits Differential Revision: https://reviews.llvm.org/D36656 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316891 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-30[IRCE][NFC] Store Length as SCEV in RangeCheck instead of ValueMax Kazantsev
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316889 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-30Revert r316887 to fix buildbot failures.Florian Hahn
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316888 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-30Recommit r315288: [SCCP] Propagate integer range info for parameters in IPSCCP.Florian Hahn
This version of the patch includes a fix addressing a stage2 LTO buildbot failure and addressed some additional nits. Original commit message: This updates the SCCP solver to use of the ValueElement lattice for parameters, which provides integer range information. The range information is used to remove unneeded icmp instructions. For the following function, f() can be optimized to ret i32 2 with this change source_filename = "sccp.c" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" ; Function Attrs: norecurse nounwind readnone uwtable define i32 @main() local_unnamed_addr #0 { entry: %call = tail call fastcc i32 @f(i32 1) %call1 = tail call fastcc i32 @f(i32 47) %add3 = add nsw i32 %call, %call1 ret i32 %add3 } ; Function Attrs: noinline norecurse nounwind readnone uwtable define internal fastcc i32 @f(i32 %x) unnamed_addr #1 { entry: %c1 = icmp sle i32 %x, 100 %cmp = icmp sgt i32 %x, 300 %. = select i1 %cmp, i32 1, i32 2 ret i32 %. } attributes #1 = { noinline } Reviewers: davide, sanjoy, efriedma, dberlin Reviewed By: davide, dberlin Subscribers: mcrosier, gberry, mssimpso, dberlin, llvm-commits Differential Revision: https://reviews.llvm.org/D36656 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316887 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-30[GVN][NFC] Mark instruction for deletion instead of immediate erasing in LoadPREMax Kazantsev
It is done to uniformly handle instructions removal. Differential Revision: https://reviews.llvm.org/D39369 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316884 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-28[SimplifyCFG] use pass options and remove the latesimplifycfg passSanjay Patel
This is no-functional-change-intended. This is repackaging the functionality of D30333 (defer switch-to-lookup-tables) and D35411 (defer folding unconditional branches) with pass parameters rather than a named "latesimplifycfg" pass. Now that we have individual options to control the functionality, we could decouple when these fire (but that's an independent patch if desired). The next planned step would be to add another option bit to disable the sinking transform mentioned in D38566. This should also make it clear that the new pass manager needs to be updated to limit simplifycfg in the same way as the old pass manager. Differential Revision: https://reviews.llvm.org/D38631 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316835 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-28[PartialInlineLibCalls] Teach PartialInlineLibCalls to honor nobuiltin, ↵Craig Topper
properly check the function signature, and check TLI::has Summary: We shouldn't do this transformation if the function is marked nobuitlin. We were only checking that the return type is floating point, we really should be checking the argument types and argument count as well. This can be accomplished by using the other version of getLibFunc that takes the Function and not just the name. We should also be checking TLI::has since sqrtf is a macro on Windows. Fixes PR32559. Reviewers: hfinkel, spatel, davide, efriedma Reviewed By: davide, efriedma Subscribers: efriedma, llvm-commits, eraman Differential Revision: https://reviews.llvm.org/D39381 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316819 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-27[LoopPredication] Handle the case when the guard and the latch IV have ↵Artur Pilipenko
different offsets This is a follow up change for D37569. Currently the transformation is limited to the case when: * The loop has a single latch with the condition of the form: ++i <pred> latchLimit, where <pred> is u<, u<=, s<, or s<=. * The step of the IV used in the latch condition is 1. * The IV of the latch condition is the same as the post increment IV of the guard condition. * The guard condition is of the form i u< guardLimit. This patch enables the transform in the case when the latch is latchStart + i <pred> latchLimit, where <pred> is u<, u<=, s<, or s<=. And the guard is guardStart + i u< guardLimit Reviewed By: anna Differential Revision: https://reviews.llvm.org/D39097 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316768 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-27[GVN][NFC] Refactor loop iteration with foreachMax Kazantsev
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316748 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-27[Transforms] Fix some Clang-tidy modernize and Include What You Use ↵Eugene Zelenko
warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316724 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-26[LICM] Restructure implicit exit handling to be more clear [NFCI]Philip Reames
When going to explain this to someone else, I got tripped up by the complicated meaning of IsKnownNonEscapingObject in load-store promotion. Extract a helper routine and clarify naming/scopes to make this a bit more obvious. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316699 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-26[Transforms] Revert r316630 changes in Scalar/MergeICmps.cpp to fix broken ↵Eugene Zelenko
build bots (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316634 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-26[Transforms] Fix some Clang-tidy modernize and Include What You Use ↵Eugene Zelenko
warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316630 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-25[IRCE] Fix intersection between signed and unsigned rangesMax Kazantsev
IRCE for unsigned latch conditions was temporarily disabled by rL314881. The motivating example contained an unsigned latch condition and a signed range check. One of the safe iteration ranges was `[1, SINT_MAX + 1]`. Its right border was incorrectly interpreted as a negative value in `IntersectRange` function, this lead to a miscompile under which we deleted a range check without inserting a postloop where it was needed. This patch brings back IRCE for unsigned latch conditions. Now we treat range intersection more carefully. If the latch condition was unsigned, we only try to consider a range check for deletion if: 1. The range check is also unsigned, or 2. Safe iteration range of the range check lies within `[0, SINT_MAX]`. The same is done for signed latch. Values from `[0, SINT_MAX]` are unambiguous, these values are non-negative under any interpretation, and all values of a range intersected with such range are also non-negative. We also use signed/unsigned min/max functions for range intersection depending on type of the latch condition. Differential Revision: https://reviews.llvm.org/D38581 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316552 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-25[IRCE] Smarter detection of empty ranges using SCEVMax Kazantsev
For a SCEV range, this patch replaces the naive emptiness check for SCEV ranges which looks like `Begin == End` with a SCEV check. The range is guaranteed to be empty of `Begin >= End`. We should filter such ranges out and do not try to perform IRCE for them. For example, we can get such range when intersecting range `[A, B)` and `[C, D)` where `A < B < C < D`. The resulting range is `[max(A, C), min(B, D)) = [C, B)`. This range is empty, but its `Begin` does not match with `End`. Making IRCE for an empty range is basically safe but unprofitable because we never actually get into the main loop where the range checks are supposed to be eliminated. This patch uses SCEV mechanisms to treat loops with proved `Begin >= End` as empty. Differential Revision: https://reviews.llvm.org/D39082 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316550 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-24[Transforms] Fix some Clang-tidy modernize and Include What You Use ↵Eugene Zelenko
warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316503 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-24[NVPTX] allow address space inference for volatile loads/stores.Artem Belevich
If particular target supports volatile memory access operations, we can avoid AS casting to generic AS. Currently it's only enabled in NVPTX for loads and stores that access global & shared AS. Differential Revision: https://reviews.llvm.org/D39026 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316495 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-23[GVNSink] Fix failing GVNSink tests in the reverse iteration botMandeep Singh Grang
Summary: The elts of ActivePreds which is defined as a SmallPtrSet are copied into Blocks using std::copy. This makes the resultant order of Blocks non-deterministic. We cannot simply sort Blocks as they need to match the corresponding Values. So a better approach is to define ActivePreds as SmallSetVector. This fixes the following failures in http://lab.llvm.org:8011/builders/reverse-iteration: LLVM :: Transforms/GVNSink/indirect-call.ll LLVM :: Transforms/GVNSink/sink-common-code.ll LLVM :: Transforms/GVNSink/struct.ll Reviewers: dberlin, jmolloy, bkramer, efriedma Reviewed By: dberlin Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39025 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316369 91177308-0d34-0410-b5e6-96231b3b80d8