summaryrefslogtreecommitdiff
path: root/contrib/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Move all sources from the llvm project into contrib/llvm-project.Dimitry Andric2019-12-201-2954/+0
| | | | | | | | | | | | | This uses the new layout of the upstream repository, which was recently migrated to GitHub, and converted into a "monorepo". That is, most of the earlier separate sub-projects with their own branches and tags were consolidated into one top-level directory, and are now branched and tagged together. Updating the vendor area to match this layout is next. Notes: svn path=/head/; revision=355940
* Merge llvm trunk r366426, resolve conflicts, and update FREEBSD-Xlist.Dimitry Andric2019-08-211-128/+249
| | | | Notes: svn path=/projects/clang900-import/; revision=351344
* Pull in r360968 from upstream llvm trunk (by Philip Reames):Dimitry Andric2019-07-011-171/+258
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clarify comments on helpers used by LFTR [NFC] I'm slowly wrapping my head around this code, and am making comment improvements where I can. Pull in r360972 from upstream llvm trunk (by Philip Reames): [LFTR] Factor out a helper function for readability purpose [NFC] Pull in r360976 from upstream llvm trunk (by Philip Reames): [IndVars] Don't reimplement Loop::isLoopInvariant [NFC] Using dominance vs a set membership check is indistinguishable from a compile time perspective, and the two queries return equivelent results. Simplify code by using the existing function. Pull in r360978 from upstream llvm trunk (by Philip Reames): [LFTR] Strengthen assertions in genLoopLimit [NFCI] Pull in r362292 from upstream llvm trunk (by Nikita Popov): [IndVarSimplify] Fixup nowrap flags during LFTR (PR31181) Fix for https://bugs.llvm.org/show_bug.cgi?id=31181 and partial fix for LFTR poison handling issues in general. When LFTR moves a condition from pre-inc to post-inc, it may now depend on value that is poison due to nowrap flags. To avoid this, we clear any nowrap flag that SCEV cannot prove for the post-inc addrec. Additionally, LFTR may switch to a different IV that is dynamically dead and as such may be arbitrarily poison. This patch will correct nowrap flags in some but not all cases where this happens. This is related to the adoption of IR nowrap flags for the pre-inc addrec. (See some of the switch_to_different_iv tests, where flags are not dropped or insufficiently dropped.) Finally, there are likely similar issues with the handling of GEP inbounds, but we don't have a test case for this yet. Differential Revision: https://reviews.llvm.org/D60935 Pull in r362971 from upstream llvm trunk (by Philip Reames): Prepare for multi-exit LFTR [NFC] This change does the plumbing to wire an ExitingBB parameter through the LFTR implementation, and reorganizes the code to work in terms of a set of individual loop exits. Most of it is fairly obvious, but there's one key complexity which makes it worthy of consideration. The actual multi-exit LFTR patch is in D62625 for context. Specifically, it turns out the existing code uses the backedge taken count from before a IV is widened. Oddly, we can end up with a different (more expensive, but semantically equivelent) BE count for the loop when requerying after widening. For the nestedIV example from elim-extend, we end up with the following BE counts: BEFORE: (-2 + (-1 * %innercount) + %limit) AFTER: (-1 + (sext i32 (-1 + %limit) to i64) + (-1 * (sext i32 %innercount to i64))<nsw>) This is the only test in tree which seems sensitive to this difference. The actual result of using the wider BETC on this example is that we actually produce slightly better code. :) In review, we decided to accept that test change. This patch is structured to preserve the old behavior, but a separate change will immediate follow with the behavior change. (I wanted it separate for problem attribution purposes.) Differential Revision: https://reviews.llvm.org/D62880 Pull in r362975 from upstream llvm trunk (by Philip Reames): [LFTR] Use recomputed BE count This was discussed as part of D62880. The basic thought is that computing BE taken count after widening should produce (on average) an equally good backedge taken count as the one before widening. Since there's only one test in the suite which is impacted by this change, and it's essentially equivelent codegen, that seems to be a reasonable assertion. This change was separated from r362971 so that if this turns out to be problematic, the triggering piece is obvious and easily revertable. For the nestedIV example from elim-extend.ll, we end up with the following BE counts: BEFORE: (-2 + (-1 * %innercount) + %limit) AFTER: (-1 + (sext i32 (-1 + %limit) to i64) + (-1 * (sext i32 %innercount to i64))<nsw>) Note that before is an i32 type, and the after is an i64. Truncating the i64 produces the i32. Pull in r362980 from upstream llvm trunk (by Philip Reames): Factor out a helper function for readability and reuse in a future patch [NFC] Pull in r363613 from upstream llvm trunk (by Philip Reames): Fix a bug w/inbounds invalidation in LFTR (recommit) Recommit r363289 with a bug fix for crash identified in pr42279. Issue was that a loop exit test does not have to be an icmp, leading to a null dereference crash when new logic was exercised for that case. Test case previously committed in r363601. Original commit comment follows: This contains fixes for two cases where we might invalidate inbounds and leave it stale in the IR (a miscompile). Case 1 is when switching to an IV with no dynamically live uses, and case 2 is when doing pre-to-post conversion on the same pointer type IV. The basic scheme used is to prove that using the given IV (pre or post increment forms) would have to already trigger UB on the path to the test we're modifying. As such, our potential UB triggering use does not change the semantics of the original program. As was pointed out in the review thread by Nikita, this is defending against a separate issue from the hasConcreteDef case. This is about poison, that's about undef. Unfortunately, the two are different, see Nikita's comment for a fuller explanation, he explains it well. (Note: I'm going to address Nikita's last style comment in a separate commit just to minimize chance of subtle bugs being introduced due to typos.) Differential Revision: https://reviews.llvm.org/D62939 Pull in r363875 from upstream llvm trunk (by Philip Reames): [LFTR] Rename variable to minimize confusion [NFC] (Recommit of r363293 which was reverted when a dependent patch was.) As pointed out by Nikita in D62625, BackedgeTakenCount is generally used to refer to the backedge taken count of the loop. A conditional backedge taken count - one which only applies if a particular exit is taken - is called a ExitCount in SCEV code, so be consistent here. Pull in r363877 from upstream llvm trunk (by Philip Reames): [LFTR] Stylistic cleanup as suggested in last review comment of D62939 [NFC] (Resumbit of r363292 which was reverted along w/an earlier patch) Pull in r364346 from upstream llvm trunk (by Philip Reames): [LFTR] Adjust debug output to include extensions (if any) Pull in r364693 from upstream llvm trunk (by Philip Reames): [IndVars] Remove a bit of manual constant folding [NFC] SCEV is more than capable of folding (add x, trunc(0)) to x. Pull in r364709 from upstream llvm trunk (by Nikita Popov): [LFTR] Fix post-inc pointer IV with truncated exit count (PR41998) Fixes https://bugs.llvm.org/show_bug.cgi?id=41998. Usually when we have a truncated exit count we'll truncate the IV when comparing against the limit, in which case exit count overflow in post-inc form doesn't matter. However, for pointer IVs we don't do that, so we have to be careful about incrementing the IV in the wide type. I'm fixing this by removing the IVCount variable (which was ExitCount or ExitCount+1) and replacing it with a UsePostInc flag, and then moving the actual limit adjustment to the individual cases (which are: pointer IV where we add to the wide type, integer IV where we add to the narrow type, and constant integer IV where we add to the wide type). Differential Revision: https://reviews.llvm.org/D63686 Together, these should fix a hang when building the textproc/htmldoc port, due to an incorrect loop optimization. PR: 237515 MFC after: 1 week Notes: svn path=/head/; revision=349583
* Merge llvm trunk r351319, resolve conflicts, and update FREEBSD-Xlist.Dimitry Andric2019-01-201-109/+255
| | | | Notes: svn path=/projects/clang800-import/; revision=343210
* Merge llvm trunk r338150, and resolve conflicts.Dimitry Andric2018-07-301-25/+28
| | | | Notes: svn path=/projects/clang700-import/; revision=336916
* Merge llvm, clang, lld, lldb, compiler-rt and libc++ release_60 r321788,Dimitry Andric2018-01-061-12/+9
| | | | | | | update build glue and version numbers. Notes: svn path=/projects/clang600-import/; revision=327657
* Merge llvm trunk r321017 to contrib/llvm.Dimitry Andric2017-12-201-36/+93
| | | | Notes: svn path=/projects/clang600-import/; revision=327023
* Merge llvm, clang, lld, lldb, compiler-rt and libc++ r305145, and updateDimitry Andric2017-06-101-1/+6
| | | | | | | build glue. Notes: svn path=/projects/clang500-import/; revision=319799
* Merge llvm, clang, lld, lldb, compiler-rt and libc++ r304659, and updateDimitry Andric2017-06-031-0/+1
| | | | | | | build glue. Notes: svn path=/projects/clang500-import/; revision=319547
* Merge llvm, clang, lld, lldb, compiler-rt and libc++ r302069, and updateDimitry Andric2017-05-031-19/+12
| | | | | | | build glue (preliminary, not all option combinations work yet). Notes: svn path=/projects/clang500-import/; revision=317778
* Merge llvm trunk r300422 and resolve conflicts.Dimitry Andric2017-04-161-7/+12
| | | | Notes: svn path=/projects/clang500-import/; revision=317029
* Merge llvm, clang, lld and lldb release_40 branch r292009. Also updateDimitry Andric2017-01-141-18/+8
| | | | | | | build glue. Notes: svn path=/projects/clang400-import/; revision=312197
* Merge llvm, clang, lld and lldb trunk r291476.Dimitry Andric2017-01-091-1/+1
| | | | Notes: svn path=/projects/clang400-import/; revision=311833
* Update llvm to trunk r290819 and resolve conflicts.Dimitry Andric2017-01-021-57/+318
| | | | Notes: svn path=/projects/clang400-import/; revision=311142
* Update llvm to release_39 branch r278877.Dimitry Andric2016-08-171-0/+8
| | | | Notes: svn path=/projects/clang390-import/; revision=304310
* Update llvm to release_39 branch r276489, and resolve conflicts.Dimitry Andric2016-08-161-116/+197
| | | | Notes: svn path=/projects/clang390-import/; revision=304240
* Update llvm to trunk r256633.Dimitry Andric2015-12-301-314/+410
| | | | Notes: svn path=/projects/clang380-import/; revision=292941
* Update llvm/clang to r242221.Dimitry Andric2015-08-121-2/+54
| | | | Notes: svn path=/projects/clang-trunk/; revision=286684
* Update llvm/clang to r241361.Dimitry Andric2015-07-051-8/+7
| | | | Notes: svn path=/projects/clang-trunk/; revision=285181
* Update llvm/clang to r240225.Dimitry Andric2015-06-231-7/+8
| | | | Notes: svn path=/projects/clang-trunk/; revision=284734
* Update Makefiles and other build glue for llvm/clang 3.7.0, as of trunkDimitry Andric2015-06-101-19/+133
| | | | | | | r239412. Notes: svn path=/projects/clang-trunk/; revision=284236
* Merge llvm trunk r238337 from ^/vendor/llvm/dist, resolve conflicts, andDimitry Andric2015-05-271-138/+38
| | | | | | | preserve our customizations, where necessary. Notes: svn path=/projects/clang-trunk/; revision=283631
* Merge llvm 3.6.0rc1 from ^/vendor/llvm/dist, merge clang 3.6.0rc1 fromDimitry Andric2015-01-251-25/+129
| | | | | | | ^/vendor/clang/dist, resolve conflicts, and cleanup patches. Notes: svn path=/projects/clang360-import/; revision=277718
* Upgrade our copy of clang and llvm to 3.5.1 release. This is a bugfixDimitry Andric2015-01-181-6/+21
| | | | | | | | | | | | | | | | | only release, no new features have been added. Please note that this version requires C++11 support to build; see UPDATING for more information. Release notes for llvm and clang can be found here: <http://llvm.org/releases/3.5.1/docs/ReleaseNotes.html> <http://llvm.org/releases/3.5.1/tools/clang/docs/ReleaseNotes.html> MFC after: 1 month X-MFC-With: 276479 Notes: svn path=/head/; revision=277320
* Merge llvm 3.5.0 release from ^/vendor/llvm/dist, resolve conflicts, andDimitry Andric2014-11-241-116/+174
| | | | | | | preserve our customizations, where necessary. Notes: svn path=/projects/clang350-import/; revision=274968
* Upgrade our copy of llvm/clang to 3.4 release. This version supportsDimitry Andric2014-02-161-38/+53
| | | | | | | | | | | | | | | | | | | | all of the features in the current working draft of the upcoming C++ standard, provisionally named C++1y. The code generator's performance is greatly increased, and the loop auto-vectorizer is now enabled at -Os and -O2 in addition to -O3. The PowerPC backend has made several major improvements to code generation quality and compile time, and the X86, SPARC, ARM32, Aarch64 and SystemZ backends have all seen major feature work. Release notes for llvm and clang can be found here: <http://llvm.org/releases/3.4/docs/ReleaseNotes.html> <http://llvm.org/releases/3.4/tools/clang/docs/ReleaseNotes.html> MFC after: 1 month Notes: svn path=/head/; revision=261991
* Upgrade our copy of llvm/clang to trunk r178860, in preparation of theDimitry Andric2013-04-121-13/+52
| | | | | | | | | | | | upcoming 3.3 release (branching and freezing expected in a few weeks). Preliminary release notes can be found at the usual location: <http://llvm.org/docs/ReleaseNotes.html> An MFC is planned once the actual 3.3 release is finished. Notes: svn path=/head/; revision=249423
* Upgrade our copy of llvm/clang to r168974, from upstream's release_32Dimitry Andric2012-12-031-17/+25
| | | | | | | | branch. This is effectively llvm/clang 3.2 RC2; the 3.2 release is coming soon. Notes: svn path=/head/; revision=243830
* Upgrade our copy of llvm/clang to trunk r162107. With thanks toDimitry Andric2012-08-201-6/+68
| | | | | | | Benjamin Kramer and Joerg Sonnenberger for their input and fixes. Notes: svn path=/head/; revision=239462
* Upgrade our copy of llvm/clang to trunk r154661, in preparation of theDimitry Andric2012-04-161-379/+174
| | | | | | | | | | upcoming 3.1 release (expected in a few weeks). Preliminary release notes can be found at: <http://llvm.org/docs/ReleaseNotes.html> MFC after: 2 weeks Notes: svn path=/head/; revision=234353
* Upgrade our copy of llvm/clang to r142614, from upstream's release_30Dimitry Andric2011-10-221-536/+606
| | | | | | | | | | branch. This brings us very close to the 3.0 release, which is expected in a week or two. MFC after: 1 week Notes: svn path=/head/; revision=226633
* Upgrade our copy of llvm/clang to r135360, from upstream's trunk.Dimitry Andric2011-07-171-742/+1030
| | | | Notes: svn path=/head/; revision=224145
* Upgrade our copy of llvm/clang to r132879, from upstream's trunk.Dimitry Andric2011-06-121-131/+630
| | | | Notes: svn path=/head/; revision=223017
* Upgrade our copy of llvm/clang to r130700, from upstream's trunk.Dimitry Andric2011-05-021-57/+98
| | | | Notes: svn path=/head/; revision=221345
* Upgrade our copy of llvm/clang to r126079, from upstream's trunk.Dimitry Andric2011-02-201-20/+29
| | | | | | | | This contains many improvements, primarily better C++ support, an integrated assembler for x86 and support for -pg. Notes: svn path=/head/; revision=218893
* Upgrade our Clang in base to r114020, from upstream's release_28 branch.Dimitry Andric2010-09-201-9/+9
| | | | | | | Approved-by: rpaulo (mentor) Notes: svn path=/head/; revision=212904
* Upgrade our Clang in base to r108428.Ed Schouten2010-07-201-2/+14
| | | | | | | | | | | | This commit merges the latest LLVM sources from the vendor space. It also updates the build glue to match the new sources. Clang's version number is changed to match LLVM's, which means /usr/include/clang/2.0 has been renamed to /usr/include/clang/2.8. Obtained from: projects/clangbsd Notes: svn path=/head/; revision=210299
* Import LLVM/clang from vendor stripped of docs/ test/ website/ www/ examples/Roman Divacky2010-06-091-0/+1022
in llvm/ and/or llvm/contrib/clang/ respectively. Approved by: ed (mentor) Approved by: core Notes: svn path=/head/; revision=208954