diff options
| author | Eli Bendersky <eliben@google.com> | 2014-05-01 18:38:36 +0000 |
|---|---|---|
| committer | Eli Bendersky <eliben@google.com> | 2014-05-01 18:38:36 +0000 |
| commit | a108a65df2716de0c12d39f189c300a17a7bde8b (patch) | |
| tree | eeb3a1831b939c633e5df5aa4a060bc36c5d0382 /llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp | |
| parent | 748be6c3760e47ff9a2c9d88a48f18d92309727b (diff) | |
| download | bcm5719-llvm-a108a65df2716de0c12d39f189c300a17a7bde8b.tar.gz bcm5719-llvm-a108a65df2716de0c12d39f189c300a17a7bde8b.zip | |
Add an optimization that does CSE in a group of similar GEPs.
This optimization merges the common part of a group of GEPs, so we can compute
each pointer address by adding a simple offset to the common part.
The optimization is currently only enabled for the NVPTX backend, where it has
a large payoff on some benchmarks.
Review: http://reviews.llvm.org/D3462
Patch by Jingyue Wu.
llvm-svn: 207783
Diffstat (limited to 'llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp')
| -rw-r--r-- | llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp index 0cc5c516292..26a4f840520 100644 --- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp @@ -147,10 +147,23 @@ void NVPTXPassConfig::addIRPasses() { addPass(createNVPTXAssignValidGlobalNamesPass()); addPass(createGenericToNVVMPass()); addPass(createNVPTXFavorNonGenericAddrSpacesPass()); - // The FavorNonGenericAddrSpaces pass may remove instructions and leave some - // values unused. Therefore, we run a DCE pass right afterwards. We could - // remove unused values in an ad-hoc manner, but it requires manual work and - // might be error-prone. + addPass(createSeparateConstOffsetFromGEPPass()); + // The SeparateConstOffsetFromGEP pass creates variadic bases that can be used + // by multiple GEPs. Run GVN or EarlyCSE to really reuse them. GVN generates + // significantly better code than EarlyCSE for some of our benchmarks. + if (getOptLevel() == CodeGenOpt::Aggressive) + addPass(createGVNPass()); + else + addPass(createEarlyCSEPass()); + // Both FavorNonGenericAddrSpaces and SeparateConstOffsetFromGEP may leave + // some dead code. We could remove dead code in an ad-hoc manner, but that + // requires manual work and might be error-prone. + // + // The FavorNonGenericAddrSpaces pass shortcuts unnecessary addrspacecasts, + // and leave them unused. + // + // SeparateConstOffsetFromGEP rebuilds a new index from the old index, and the + // old index and some of its intermediate results may become unused. addPass(createDeadCodeEliminationPass()); } |

