llvm-project/llvm/lib/Transforms
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
..
AggressiveInstCombine [llvm] Use llvm::reverse (NFC) 2021-11-06 19:31:18 -07:00
CFGuard llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
Coroutines [Transforms] Use make_early_inc_range (NFC) 2021-11-07 17:03:15 -08:00
Hello
IPO [OpenMP] Fix main thread barrier for Pascal and amdgpu 2021-11-12 11:18:45 -05:00
InstCombine [InstCombine] Drop redundant fold for and/or of icmp eq/ne (NFCI) 2021-11-11 20:25:40 +01:00
Instrumentation [sancov] add tracing for loads and store 2021-11-09 14:35:13 -08:00
ObjCARC [ObjC][ARC] Handle operand bundle "clang.arc.attachedcall" on targets 2021-11-08 18:38:39 -08:00
Scalar Reapply 5ec2386 "Reapply db28934 "[IndVars] Pass TTI to replaceCongruentIVs"" 2021-11-10 17:36:14 +07:00
Utils [runtime-unroll] Use incrementing IVs instead of decrementing ones 2021-11-12 15:44:58 -08:00
Vectorize [SLP]Improve vectorization of split loads. 2021-11-12 06:13:22 -08:00
CMakeLists.txt [NewPM][HelloWorld] Move HelloWorld to Utils 2021-02-03 12:59:40 -08:00