llvm-project/llvm/lib
Florian Hahn bee486851c
[LoopUnswitch] Implement first version of partial unswitching.
This patch applies the idea from D93734 to LoopUnswitch.

It adds support for unswitching on conditions that are only
invariant along certain paths through a loop.

In particular, it targets conditions in the loop header that
depend on values loaded from memory. If either path from
the true or false successor through the loop does not modify
memory, perform partial loop unswitching.

That is, duplicate the instructions feeding the condition in the pre-header.
Then unswitch on the duplicated condition. The condition is now known
in the unswitched version for the 'invariant' path through the original loop.

On caveat of this approach is that one of the loops created can be partially
unswitched again. To avoid this behavior, `llvm.loop.unswitch.partial.disable`
metadata is added to the unswitched loops, to avoid subsequent partial
unswitching.

If that's the approach to go, I can move the code handling the metadata kind
into separate functions.

This increases the cases we unswitch quite a bit in SPEC2006/SPEC2000 &
MultiSource. It also allows us to eliminate a dead loop in SPEC2017's omnetpp

```
Tests: 236
Same hash: 170 (filtered out)
Remaining: 66
Metric: loop-unswitch.NumBranches

Program                                        base   patch  diff
 test-suite...000/255.vortex/255.vortex.test     2.00  23.00 1050.0%
 test-suite...T2006/401.bzip2/401.bzip2.test     7.00  55.00 685.7%
 test-suite :: External/Nurbs/nurbs.test         5.00  26.00 420.0%
 test-suite...s-C/unix-smail/unix-smail.test     1.00   3.00 200.0%
 test-suite.../Prolangs-C++/ocean/ocean.test     1.00   3.00 200.0%
 test-suite...tions/lambda-0.1.3/lambda.test     1.00   3.00 200.0%
 test-suite...yApps-C++/PENNANT/PENNANT.test     2.00   5.00 150.0%
 test-suite...marks/Ptrdist/yacr2/yacr2.test     1.00   2.00 100.0%
 test-suite...lications/viterbi/viterbi.test     1.00   2.00 100.0%
 test-suite...plications/d/make_dparser.test    12.00  24.00 100.0%
 test-suite...CFP2006/433.milc/433.milc.test    14.00  27.00 92.9%
 test-suite.../Applications/lemon/lemon.test     7.00  12.00 71.4%
 test-suite...ce/Applications/Burg/burg.test     6.00  10.00 66.7%
 test-suite...T2006/473.astar/473.astar.test    16.00  26.00 62.5%
 test-suite...marks/7zip/7zip-benchmark.test    78.00 121.00 55.1%
```

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D93764
2021-01-21 09:46:41 +00:00
..
Analysis [llvm] Construct SmallVector with iterator ranges (NFC) 2021-01-20 21:35:52 -08:00
AsmParser [X86] Add x86_amx type for intel AMX. 2020-12-30 13:52:13 +08:00
BinaryFormat [Debuginfo][DW_OP_implicit_pointer] (1/7) Support for DW_OP_LLVM_implicit_pointer 2021-01-15 14:45:04 +05:30
Bitcode [llvm] Use llvm::sort (NFC) 2021-01-17 10:39:45 -08:00
Bitstream [llvm] Use llvm::append_range (NFC) 2021-01-06 18:27:33 -08:00
CodeGen [X86][AMX] Fix tile config register spill issue. 2021-01-21 16:01:50 +08:00
DWARFLinker [llvm] Use llvm::sort (NFC) 2021-01-17 10:39:45 -08:00
DebugInfo [llvm] Use hasSingleElement (NFC) 2021-01-20 21:35:55 -08:00
Demangle [llvm] Remove redundant return and continue statements (NFC) 2021-01-14 20:30:34 -08:00
ExecutionEngine [ORC] Move LookupRequest from OrcShared to Orc. 2021-01-19 20:23:47 +11:00
Extensions llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
FileCheck [llvm] Use llvm::sort (NFC) 2021-01-17 10:39:45 -08:00
Frontend [OpenMPOpt][WIP] Expand parallel region merging 2021-01-11 08:06:23 -08:00
FuzzMutate llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
Fuzzer
IR [PM] Avoid duplicates in the Used/Preserved/Required sets 2021-01-20 13:55:18 +01:00
IRReader static const char *const foo => const char foo[] 2020-12-01 10:33:18 -08:00
InterfaceStub [llvm-elfabi] Add flag to preserve timestamp when output is the same 2020-12-29 20:27:06 -08:00
LTO [lld-macho] Run ObjCContractPass during LTO 2021-01-20 14:21:32 -05:00
LineEditor llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
Linker [ExecutionEngine, Linker] Use erase_if (NFC) 2020-12-23 21:44:39 -08:00
MC MCDwarf: Delete uneeded parameter 2021-01-21 00:55:07 -08:00
MCA [llvm] Use llvm::find (NFC) 2021-01-19 20:19:14 -08:00
Object [WebAssembly] Change prefix on data segment flags to WASM_DATA_SEGMENT 2021-01-19 09:40:42 +01:00
ObjectYAML [yaml2obj/obj2yaml] - Improve dumping/creating of ELF versioning sections. 2021-01-21 10:36:48 +03:00
Option [llvm] Simplify string comparisons (NFC) 2021-01-11 18:48:09 -08:00
Passes [LoopRotate] Add PrepareForLTO stage, avoid rotating with inline cands. 2021-01-19 10:15:29 +00:00
ProfileData [SampleFDO] Add the support to split the function profiles with context into 2021-01-19 15:16:19 -08:00
Remarks llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
Support D94954: Fixes Snapdragon Kryo CPU core detection 2021-01-20 22:23:43 +00:00
TableGen Revert "[TableGen] Improve algorithm for inheriting class template args and fields" 2021-01-20 09:47:13 -05:00
Target [X86][AMX] Fix tile config register spill issue. 2021-01-21 16:01:50 +08:00
Testing [llvm][NFC] Remove unnecessary vector creation in Annotations 2020-11-14 15:55:09 +00:00
TextAPI [llvm] Use llvm::sort (NFC) 2021-01-17 10:39:45 -08:00
ToolDrivers llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
Transforms [LoopUnswitch] Implement first version of partial unswitching. 2021-01-21 09:46:41 +00:00
WindowsManifest llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
XRay [lib/Object, tools] - Make ELFObjectFile::getELFFile return reference. 2020-12-04 16:02:29 +03:00
CMakeLists.txt llvmbuildectomy - support disabled native target 2020-11-13 15:50:13 +01:00