llvm-project/llvm/lib/Transforms
Chandler Carruth 4cbcbb0761 [LoopInstSimplify] Re-implement the core logic of loop-instsimplify to
be both simpler and substantially more efficient.

Rather than use a hand-rolled iteration technique that isn't quite the
same as RPO, use the pre-built RPO loop body traversal utility.

Once visiting the loop body in RPO, we can assert that we visit defs
before uses reliably. When this is the case, the only need to iterate is
when simplifying a def that is used by a PHI node along a back-edge.
With this patch, the first pass over the loop body is just a complete
simplification of every instruction across the loop body. When we
encounter a use of a simplified instruction that stems from a PHI node
in the loop body that has already been visited (due to some cyclic CFG,
potentially the loop itself, or a nested loop, or unstructured control
flow), we recall that specific PHI node for the second iteration.
Nothing else needs to be preserved from iteration to iteration.

On the second and later iterations, only instructions known to have
simplified inputs are considered, each time starting from a set of PHIs
that had simplified inputs along the backedges.

Dead instructions are collected along the way, but deleted in a batch at
the end of each iteration making the iterations themselves substantially
simpler. This uses a new batch API for recursively deleting dead
instructions.

This alsa changes the routine to visit subloops. Because simplification
is fundamentally transitive, we may need to visit the entire loop body,
including subloops, to handle knock-on simplification.

I've added a basic test file that helps demonstrate that all of these
changes work. It includes both straight-forward loops with
simplifications as well as interesting PHI-structures, CFG-structures,
and a nested loop case.

Differential Revision: https://reviews.llvm.org/D47407

llvm-svn: 333461
2018-05-29 20:15:38 +00:00
..
AggressiveInstCombine [AggressiveInstCombine] avoid crashing on unsimplified code (PR37446) 2018-05-14 13:43:32 +00:00
Coroutines Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
Hello
IPO Revert 333358 as it's failing on some builders. 2018-05-27 12:54:33 +00:00
InstCombine [InstCombine] Combine XOR and AES instructions on ARM/ARM64. 2018-05-24 15:26:42 +00:00
Instrumentation [msan] Don't check divisor shadow in fdiv. 2018-05-18 20:19:53 +00:00
ObjCARC [WebAssembly] Add Wasm personality and isScopedEHPersonality() 2018-05-17 20:52:03 +00:00
Scalar [LoopInstSimplify] Re-implement the core logic of loop-instsimplify to 2018-05-29 20:15:38 +00:00
Utils [LoopInstSimplify] Re-implement the core logic of loop-instsimplify to 2018-05-29 20:15:38 +00:00
Vectorize [LLVM-C] [OCaml] Remove LLVMAddBBVectorizePass 2018-05-28 16:58:10 +00:00
CMakeLists.txt Another try to commit 323321 (aggressive instruction combine). 2018-01-25 12:06:32 +00:00
LLVMBuild.txt Another try to commit 323321 (aggressive instruction combine). 2018-01-25 12:06:32 +00:00