diff options
author | Anna Thomas <anna@azul.com> | 2016-06-23 20:22:22 +0000 |
---|---|---|
committer | Anna Thomas <anna@azul.com> | 2016-06-23 20:22:22 +0000 |
commit | dce5fb2295d1e5611d77f35397c4becbd13481a7 (patch) | |
tree | 2ee9a6f51840e7fa86cdf026dbe926e260c0da22 /include | |
parent | dfb588ccfc0865bb7679ad21a3b431998b119cfd (diff) |
InstCombine rule to fold trunc when value available
Summary:
This instcombine rule folds away trunc operations that have value available from a prior load or store.
This kind of code can be generated as a result of GVN widening the load or from source code as well.
Reviewers: reames, majnemer, sanjoy
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D21246
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273608 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Analysis/Loads.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/llvm/Analysis/Loads.h b/include/llvm/Analysis/Loads.h index 9d24b7b2928..cf1f5bbfb44 100644 --- a/include/llvm/Analysis/Loads.h +++ b/include/llvm/Analysis/Loads.h @@ -61,6 +61,38 @@ bool isSafeToLoadUnconditionally(Value *V, unsigned Align, /// to scan in the block, used by FindAvailableLoadedValue(). extern cl::opt<unsigned> DefMaxInstsToScan; +/// Scan the ScanBB block backwards checking to see if we have the value at +/// the memory address \p Ptr of type \p AccessTy locally available within a +/// small number of instructions. If the value is available, return it. +/// +/// If not, return the iterator for the last validated instruction that the +/// value would be live through. If we scanned the entire block and didn't +/// find something that invalidates *Ptr or provides it, ScanFrom would be +/// left at begin() and this returns null. ScanFrom could also be left +/// +/// MaxInstsToScan specifies the maximum instructions to scan in the block. +/// If it is set to 0, it will scan the whole block. You can also optionally +/// specify an alias analysis implementation, which makes this more precise. +/// +/// If AATags is non-null and a load or store is found, the AA tags from the +/// load or store are recorded there. If there are no AA tags or if no access +/// is found, it is left unmodified. +/// +/// IsAtomicMemOp specifies the atomicity of the memory operation that accesses +/// \p *Ptr. We verify atomicity constraints are satisfied when value forwarding +/// from another memory operation that has value \p *Ptr available. +/// +/// Note that we assume the \p *Ptr is accessed through a non-volatile but +/// potentially atomic load. Any other constraints should be verified at the +/// caller. +Value *FindAvailableLoadedValue(Value *Ptr, Type *AccessTy, bool IsAtomicMemOp, + BasicBlock *ScanBB, + BasicBlock::iterator &ScanFrom, + unsigned MaxInstsToScan, + AliasAnalysis *AA = nullptr, + AAMDNodes *AATags = nullptr, + bool *IsLoadCSE = nullptr); + /// FindAvailableLoadedValue - Scan the ScanBB block backwards (starting at /// the instruction before ScanFrom) checking to see if we have the value at /// the memory address *Ptr locally available within a small number of |