forked from OSchip/llvm-project
[CGP] fix variables to be unsigned in memcmp expansion
llvm-svn: 305935
This commit is contained in:
parent
50f2aa19e8
commit
a10f5b626d
|
@ -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::emitLoadCompareBlockMultipleLoads(
|
|||
// 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::emitMemCmpResultBlock() {
|
|||
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::getMemCmpExpansion(uint64_t Size) {
|
|||
// 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
|
||||
|
|
Loading…
Reference in New Issue