[llvm] r304908 - [CGP] add helper function for generating compare of load pairs; NFCI
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 7 06:33:00 PDT 2017
Author: spatel
Date: Wed Jun 7 08:33:00 2017
New Revision: 304908
URL: http://llvm.org/viewvc/llvm-project?rev=304908&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
Modified: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp?rev=304908&r1=304907&r2=304908&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Wed Jun 7 08:33:00 2017
@@ -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(un
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::emitLoadCompareBlo
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];
More information about the llvm-commits
mailing list