diff options
author | Sanjay Patel <spatel@rotateright.com> | 2017-06-07 13:33:00 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2017-06-07 13:33:00 +0000 |
commit | 6007000824f886ef69298abf0d5928381b6a1f9a (patch) | |
tree | 8b1c4c18f78fe14b88cf63da5a2f05d697b54644 /llvm/lib/CodeGen | |
parent | d8623f0825d5e0cd1f8a0e9605f081613a18ff63 (diff) | |
download | bcm5719-llvm-6007000824f886ef69298abf0d5928381b6a1f9a.tar.gz bcm5719-llvm-6007000824f886ef69298abf0d5928381b6a1f9a.zip |
[CGP] add helper function for generating compare of load pairs; NFCI
In the special (but also the likely common) case, we can avoid
the multi-block complexity of the general algorithm, so moving
this part off on its own will make it re-usable.
llvm-svn: 304908
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 3da61ca0bdc..ac1e0b46fcd 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -1668,6 +1668,8 @@ class MemCmpExpansion { void setupEndBlockPHINodes(); void emitLoadCompareBlock(unsigned Index, int LoadSize, int GEPIndex, bool IsLittleEndian); + Value *getCompareLoadPairs(unsigned Index, unsigned Size, + unsigned &NumBytesProcessed, IRBuilder<> &Builder); void emitLoadCompareBlockMultipleLoads(unsigned Index, unsigned Size, unsigned &NumBytesProcessed); void emitLoadCompareByteBlock(unsigned Index, int GEPIndex); @@ -1799,11 +1801,12 @@ unsigned MemCmpExpansion::getLoadSize(unsigned Size) { return MinAlign(PowerOf2Floor(Size), MaxLoadSize); } -void MemCmpExpansion::emitLoadCompareBlockMultipleLoads( - unsigned Index, unsigned Size, unsigned &NumBytesProcessed) { - - IRBuilder<> Builder(CI->getContext()); - +/// Generate an equality comparison for one or more pairs of loaded values. +/// This is used in the case where the memcmp() call is compared equal or not +/// equal to zero. +Value *MemCmpExpansion::getCompareLoadPairs(unsigned Index, unsigned Size, + unsigned &NumBytesProcessed, + IRBuilder<> &Builder) { std::vector<Value *> XorList, OrList; Value *Diff; @@ -1880,6 +1883,14 @@ void MemCmpExpansion::emitLoadCompareBlockMultipleLoads( Cmp = Builder.CreateICmpNE(OrList[0], ConstantInt::get(Diff->getType(), 0)); } + return Cmp; +} + +void MemCmpExpansion::emitLoadCompareBlockMultipleLoads( + unsigned Index, unsigned Size, unsigned &NumBytesProcessed) { + IRBuilder<> Builder(CI->getContext()); + Value *Cmp = getCompareLoadPairs(Index, Size, NumBytesProcessed, Builder); + BasicBlock *NextBB = (Index == (LoadCmpBlocks.size() - 1)) ? EndBlock : LoadCmpBlocks[Index + 1]; |