llvm-project/llvm/test
Philip Reames eda1ba65ca LFTR for multiple exit loops
Teach IndVarSimply's LinearFunctionTestReplace transform to handle multiple exit loops. LFTR does two key things 1) it rewrites (all) exit tests in terms of a common IV potentially eliminating one in the process and 2) it moves any offset/indexing/f(i) style logic out of the loop.

This turns out to actually be pretty easy to implement. SCEV already has all the information we need to know what the backedge taken count is for each individual exit. (We use that when computing the BE taken count for the loop as a whole.) We basically just need to iterate through the exiting blocks and apply the existing logic with the exit specific BE taken count. (The previously landed NFC makes this super obvious.)

I chose to go ahead and apply this to all loop exits instead of only latch exits as originally proposed. After reviewing other passes, the only case I could find where LFTR form was harmful was LoopPredication. I've fixed the latch case, and guards aren't LFTRed anyways. We'll have some more work to do on the way towards widenable_conditions, but that's easily deferred.

I do want to note that I added one bit after the review.  When running tests, I saw a new failure (no idea why didn't see previously) which pointed out LFTR can rewrite a constant condition back to a loop varying one.  This was theoretically possible with a single exit, but the zero case covered it in practice.  With multiple exits, we saw this happening in practice for the eliminate-comparison.ll test case because we'd compute a ExitCount for one of the exits which was guaranteed to never actually be reached.  Since LFTR ran after simplifyAndExtend, we'd immediately turn around and undo the simplication work we'd just done.  The solution seemed obvious, so I didn't bother with another round of review.

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

llvm-svn: 363883
2019-06-19 21:58:25 +00:00
..
Analysis [MemorySSA] Cleanup trivial phis. 2019-06-19 21:33:09 +00:00
Assembler hwasan: Add a tag_offset DWARF attribute to instrumented stack variables. 2019-06-17 23:39:41 +00:00
Bindings
Bitcode [SVE][IR] Scalable Vector IR Type with pr42210 fix 2019-06-18 10:11:56 +00:00
BugPoint
CodeGen AMDGPU: Fix folding immediate into readfirstlane through reg_sequence 2019-06-19 20:44:15 +00:00
DebugInfo [llvm-dwarfdump] --gdb-index: fix uninitialized TuListOffset 2019-06-19 13:51:29 +00:00
Demangle llvm-undname: Correctly demangle vararg parameters 2019-06-04 19:10:08 +00:00
Examples
ExecutionEngine [lit] Delete empty lines at the end of lit.local.cfg NFC 2019-06-17 09:51:07 +00:00
Feature
FileCheck FileCheck [6/12]: Introduce numeric variable definition 2019-06-06 13:21:06 +00:00
Instrumentation [DFSan] Add UnaryOperator visitor to DataFlowSanitizer 2019-06-19 15:11:41 +00:00
Integer
JitListener [lit] Delete empty lines at the end of lit.local.cfg NFC 2019-06-17 09:51:07 +00:00
LTO [ThinLTO]LTO]Legacy] Fix dependent libraries support by adding querying of the IRSymtab 2019-06-12 11:07:56 +00:00
Linker Reapply: IR: add optional type to 'byval' function parameters 2019-05-30 18:48:23 +00:00
MC [ARM] Add MVE vector bit-operations (register inputs). 2019-06-19 16:43:53 +00:00
MachineVerifier Fix GlobalISel MachineVerifier tests. NFC. 2019-06-19 18:15:45 +00:00
Object [lit] Delete empty lines at the end of lit.local.cfg NFC 2019-06-17 09:51:07 +00:00
ObjectYAML [yaml2obj][MachO] Don't fill dummy data for virtual sections 2019-06-17 02:07:20 +00:00
Other [lit] Delete empty lines at the end of lit.local.cfg NFC 2019-06-17 09:51:07 +00:00
SafepointIRVerifier
Support
SymbolRewriter
TableGen
ThinLTO/X86 [Remarks] Extend -fsave-optimization-record to specify the format 2019-06-17 16:06:00 +00:00
Transforms LFTR for multiple exit loops 2019-06-19 21:58:25 +00:00
Unit
Verifier Add debug location verification for !llvm.loop attachments. 2019-06-18 20:09:09 +00:00
YAMLParser
tools [llvm-readobj] Match GNU output for DT_RPATH and DT_RUNPATH when dumping dynamic symbol table. 2019-06-19 19:31:07 +00:00
.clang-format
CMakeLists.txt [tools] Introduce llvm-lipo 2019-05-28 23:22:12 +00:00
TestRunner.sh
lit.cfg.py
lit.site.cfg.py.in