[llvm] r305935 - [CGP] fix variables to be unsigned in memcmp expansion
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 21 11:06:13 PDT 2017
Author: spatel
Date: Wed Jun 21 13:06:13 2017
New Revision: 305935
URL: http://llvm.org/viewvc/llvm-project?rev=305935&view=rev
Log:
[CGP] fix variables to be unsigned in memcmp expansion
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=305935&r1=305934&r2=305935&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Wed Jun 21 13:06:13 2017
@@ -1663,17 +1663,18 @@ class MemCmpExpansion {
bool IsUsedForZeroCmp;
const DataLayout &DL;
- int calculateNumBlocks(unsigned Size);
+ unsigned calculateNumBlocks(unsigned Size);
void createLoadCmpBlocks();
void createResultBlock();
void setupResultBlockPHINodes();
void setupEndBlockPHINodes();
- void emitLoadCompareBlock(unsigned Index, int LoadSize, int GEPIndex);
+ void emitLoadCompareBlock(unsigned Index, unsigned LoadSize,
+ unsigned GEPIndex);
Value *getCompareLoadPairs(unsigned Index, unsigned Size,
unsigned &NumBytesProcessed, IRBuilder<> &Builder);
void emitLoadCompareBlockMultipleLoads(unsigned Index, unsigned Size,
unsigned &NumBytesProcessed);
- void emitLoadCompareByteBlock(unsigned Index, int GEPIndex);
+ void emitLoadCompareByteBlock(unsigned Index, unsigned GEPIndex);
void emitMemCmpResultBlock();
Value *getMemCmpExpansionZeroCase(unsigned Size);
Value *getMemCmpEqZeroOneBlock(unsigned Size);
@@ -1751,7 +1752,8 @@ void MemCmpExpansion::createResultBlock(
// It loads 1 byte from each source of the memcmp parameters with the given
// GEPIndex. It then subtracts the two loaded values and adds this result to the
// final phi node for selecting the memcmp result.
-void MemCmpExpansion::emitLoadCompareByteBlock(unsigned Index, int GEPIndex) {
+void MemCmpExpansion::emitLoadCompareByteBlock(unsigned Index,
+ unsigned GEPIndex) {
IRBuilder<> Builder(CI->getContext());
Value *Source1 = CI->getArgOperand(0);
@@ -1936,8 +1938,8 @@ void MemCmpExpansion::emitLoadCompareBlo
// the EndBlock if this is the last LoadCmpBlock. Loading 1 byte is handled with
// a special case through emitLoadCompareByteBlock. The special handling can
// simply subtract the loaded values and add it to the result phi node.
-void MemCmpExpansion::emitLoadCompareBlock(unsigned Index, int LoadSize,
- int GEPIndex) {
+void MemCmpExpansion::emitLoadCompareBlock(unsigned Index, unsigned LoadSize,
+ unsigned GEPIndex) {
if (LoadSize == 1) {
MemCmpExpansion::emitLoadCompareByteBlock(Index, GEPIndex);
return;
@@ -2044,8 +2046,8 @@ void MemCmpExpansion::emitMemCmpResultBl
PhiRes->addIncoming(Res, ResBlock.BB);
}
-int MemCmpExpansion::calculateNumBlocks(unsigned Size) {
- int NumBlocks = 0;
+unsigned MemCmpExpansion::calculateNumBlocks(unsigned Size) {
+ unsigned NumBlocks = 0;
bool HaveOneByteLoad = false;
unsigned RemainingSize = Size;
unsigned LoadSize = MaxLoadSize;
@@ -2114,13 +2116,13 @@ Value *MemCmpExpansion::getMemCmpExpansi
// memcmp sources. It starts with loading using the maximum load size set by
// the target. It processes any remaining bytes using a load size which is the
// next smallest power of 2.
- int LoadSize = MaxLoadSize;
- int NumBytesToBeProcessed = Size;
+ unsigned LoadSize = MaxLoadSize;
+ unsigned NumBytesToBeProcessed = Size;
unsigned Index = 0;
while (NumBytesToBeProcessed) {
// Calculate how many blocks we can create with the current load size.
- int NumBlocks = NumBytesToBeProcessed / LoadSize;
- int GEPIndex = (Size - NumBytesToBeProcessed) / LoadSize;
+ unsigned NumBlocks = NumBytesToBeProcessed / LoadSize;
+ unsigned GEPIndex = (Size - NumBytesToBeProcessed) / LoadSize;
NumBytesToBeProcessed = NumBytesToBeProcessed % LoadSize;
// For each NumBlocks, populate the instruction sequence for loading and
More information about the llvm-commits
mailing list