llvm-project/llvm
Philip Reames 37ead201e6 [runtime-unroll] Use incrementing IVs instead of decrementing ones
This is one of those wonderful "in theory X doesn't matter, but in practice is does" changes. In this particular case, we shift the IVs inserted by the runtime unroller to clamp iteration count of the loops* from decrementing to incrementing.

Why does this matter?  A couple of reasons:
* SCEV doesn't have a native subtract node.  Instead, all subtracts (A - B) are represented as A + -1 * B and drops any flags invalidated by such.  As a result, SCEV is slightly less good at reasoning about edge cases involving decrementing addrecs than incrementing ones.  (You can see this in the inferred flags in some of the test cases.)
* Other parts of the optimizer produce incrementing IVs, and they're common in idiomatic source language.  We do have support for reversing IVs, but in general if we produce one of each, the pair will persist surprisingly far through the optimizer before being coalesced.  (You can see this looking at nearby phis in the test cases.)

Note that if the hardware prefers decrementing (i.e. zero tested) loops, LSR should convert back immediately before codegen.

* Mostly irrelevant detail: The main loop of the prolog case is handled independently and will simple use the original IV with a changed start value.  We could in theory use this scheme for all iteration clamping, but that's a larger and more invasive change.
2021-11-12 15:44:58 -08:00
..
benchmarks
bindings
cmake [TableGen] Emit a warning for unused template args 2021-11-03 11:55:07 +00:00
docs Revert "[DebugInfo] Enforce implicit constraints on `distinct` MDNodes" 2021-11-09 14:27:55 -08:00
examples Revert "Use `GNUInstallDirs` to support custom installation dirs. -- LLVM" 2021-11-02 19:11:44 +01:00
include IR: Fix const-correctness of SwitchInst::CaseIterator and CaseHandle 2021-11-12 14:07:04 -08:00
lib [runtime-unroll] Use incrementing IVs instead of decrementing ones 2021-11-12 15:44:58 -08:00
projects Remove unused parallel-libs project 2021-10-21 14:34:39 -07:00
resources
runtimes
test [runtime-unroll] Use incrementing IVs instead of decrementing ones 2021-11-12 15:44:58 -08:00
tools [llvm-profgen] Fix bug of setting function entry 2021-11-12 12:18:43 -08:00
unittests ADT: Avoid repeating iterator adaptor/facade template params, NFC 2021-11-12 14:00:08 -08:00
utils [gn build] Fix Android compiler-rt targets 2021-11-11 18:41:18 -08:00
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt [NFC] Inclusive language: Remove instances of master in URLs 2021-11-05 08:48:41 -05:00
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in

README.txt

The LLVM Compiler Infrastructure
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.