Skip to content

Commit b4b7df9

Browse files
committed
[CGP] fix formatting/typos in MemCmpExpansion; NFC
llvm-svn: 304830
1 parent 0c2fca9 commit b4b7df9

File tree

1 file changed

+34
-36
lines changed

1 file changed

+34
-36
lines changed

llvm/lib/CodeGen/CodeGenPrepare.cpp

+34-36
Original file line numberDiff line numberDiff line change
@@ -1753,13 +1753,13 @@ void MemCmpExpansion::emitLoadCompareByteBlock(unsigned Index, int GEPIndex) {
17531753

17541754
Builder.SetInsertPoint(LoadCmpBlocks[Index]);
17551755
Type *LoadSizeType = Type::getInt8Ty(CI->getContext());
1756-
// Cast source to LoadSizeType*
1756+
// Cast source to LoadSizeType*.
17571757
if (Source1->getType() != LoadSizeType)
17581758
Source1 = Builder.CreateBitCast(Source1, LoadSizeType->getPointerTo());
17591759
if (Source2->getType() != LoadSizeType)
17601760
Source2 = Builder.CreateBitCast(Source2, LoadSizeType->getPointerTo());
17611761

1762-
// Get the base address using the GEPIndex
1762+
// Get the base address using the GEPIndex.
17631763
if (GEPIndex != 0) {
17641764
Source1 = Builder.CreateGEP(LoadSizeType, Source1,
17651765
ConstantInt::get(LoadSizeType, GEPIndex));
@@ -1777,16 +1777,15 @@ void MemCmpExpansion::emitLoadCompareByteBlock(unsigned Index, int GEPIndex) {
17771777
PhiRes->addIncoming(Diff, LoadCmpBlocks[Index]);
17781778

17791779
if (Index < (LoadCmpBlocks.size() - 1)) {
1780-
// Early exit branch if difference found to EndBlock, otherwise continue to
1781-
// next LoadCmpBlock
1782-
1780+
// Early exit branch if difference found to EndBlock. Otherwise, continue to
1781+
// next LoadCmpBlock,
17831782
Value *Cmp = Builder.CreateICmp(ICmpInst::ICMP_NE, Diff,
17841783
ConstantInt::get(Diff->getType(), 0));
17851784
BranchInst *CmpBr =
17861785
BranchInst::Create(EndBlock, LoadCmpBlocks[Index + 1], Cmp);
17871786
Builder.Insert(CmpBr);
17881787
} else {
1789-
// The last block has an unconditional branch to EndBlock
1788+
// The last block has an unconditional branch to EndBlock.
17901789
BranchInst *CmpBr = BranchInst::Create(EndBlock);
17911790
Builder.Insert(CmpBr);
17921791
}
@@ -1826,21 +1825,21 @@ void MemCmpExpansion::emitLoadCompareBlockMultipleLoads(
18261825
Value *Source1 = CI->getArgOperand(0);
18271826
Value *Source2 = CI->getArgOperand(1);
18281827

1829-
// Cast source to LoadSizeType*
1828+
// Cast source to LoadSizeType*.
18301829
if (Source1->getType() != LoadSizeType)
18311830
Source1 = Builder.CreateBitCast(Source1, LoadSizeType->getPointerTo());
18321831
if (Source2->getType() != LoadSizeType)
18331832
Source2 = Builder.CreateBitCast(Source2, LoadSizeType->getPointerTo());
18341833

1835-
// Get the base address using the GEPIndex
1834+
// Get the base address using the GEPIndex.
18361835
if (GEPIndex != 0) {
18371836
Source1 = Builder.CreateGEP(LoadSizeType, Source1,
18381837
ConstantInt::get(LoadSizeType, GEPIndex));
18391838
Source2 = Builder.CreateGEP(LoadSizeType, Source2,
18401839
ConstantInt::get(LoadSizeType, GEPIndex));
18411840
}
18421841

1843-
// Load LoadSizeType from the base address
1842+
// Load LoadSizeType from the base address.
18441843
Value *LoadSrc1 = Builder.CreateLoad(LoadSizeType, Source1);
18451844
Value *LoadSrc2 = Builder.CreateLoad(LoadSizeType, Source2);
18461845
if (LoadSizeType != MaxLoadType) {
@@ -1863,10 +1862,10 @@ void MemCmpExpansion::emitLoadCompareBlockMultipleLoads(
18631862
return OutList;
18641863
};
18651864

1866-
// Pair wise OR the XOR results
1865+
// Pairwise OR the XOR results.
18671866
OrList = pairWiseOr(XorList);
18681867

1869-
// Pair wise OR the OR results until one result left
1868+
// Pairwise OR the OR results until one result left.
18701869
while (OrList.size() != 1) {
18711870
OrList = pairWiseOr(OrList);
18721871
}
@@ -1876,14 +1875,14 @@ void MemCmpExpansion::emitLoadCompareBlockMultipleLoads(
18761875
BasicBlock *NextBB = (Index == (LoadCmpBlocks.size() - 1))
18771876
? EndBlock
18781877
: LoadCmpBlocks[Index + 1];
1879-
// Early exit branch if difference found to ResultBlock, otherwise continue to
1880-
// next LoadCmpBlock or EndBlock.
1878+
// Early exit branch if difference found to ResultBlock. Otherwise,
1879+
// continue to next LoadCmpBlock or EndBlock.
18811880
BranchInst *CmpBr = BranchInst::Create(ResBlock.BB, NextBB, Cmp);
18821881
Builder.Insert(CmpBr);
18831882

18841883
// Add a phi edge for the last LoadCmpBlock to Endblock with a value of 0
18851884
// since early exit to ResultBlock was not taken (no difference was found in
1886-
// any of the bytes)
1885+
// any of the bytes).
18871886
if (Index == LoadCmpBlocks.size() - 1) {
18881887
Value *Zero = ConstantInt::get(Type::getInt32Ty(CI->getContext()), 0);
18891888
PhiRes->addIncoming(Zero, LoadCmpBlocks[Index]);
@@ -1915,21 +1914,21 @@ void MemCmpExpansion::emitLoadCompareBlock(unsigned Index, int LoadSize,
19151914
Value *Source2 = CI->getArgOperand(1);
19161915

19171916
Builder.SetInsertPoint(LoadCmpBlocks[Index]);
1918-
// Cast source to LoadSizeType*
1917+
// Cast source to LoadSizeType*.
19191918
if (Source1->getType() != LoadSizeType)
19201919
Source1 = Builder.CreateBitCast(Source1, LoadSizeType->getPointerTo());
19211920
if (Source2->getType() != LoadSizeType)
19221921
Source2 = Builder.CreateBitCast(Source2, LoadSizeType->getPointerTo());
19231922

1924-
// Get the base address using the GEPIndex
1923+
// Get the base address using the GEPIndex.
19251924
if (GEPIndex != 0) {
19261925
Source1 = Builder.CreateGEP(LoadSizeType, Source1,
19271926
ConstantInt::get(LoadSizeType, GEPIndex));
19281927
Source2 = Builder.CreateGEP(LoadSizeType, Source2,
19291928
ConstantInt::get(LoadSizeType, GEPIndex));
19301929
}
19311930

1932-
// Load LoadSizeType from the base address
1931+
// Load LoadSizeType from the base address.
19331932
Value *LoadSrc1 = Builder.CreateLoad(LoadSizeType, Source1);
19341933
Value *LoadSrc2 = Builder.CreateLoad(LoadSizeType, Source2);
19351934

@@ -1961,14 +1960,14 @@ void MemCmpExpansion::emitLoadCompareBlock(unsigned Index, int LoadSize,
19611960
BasicBlock *NextBB = (Index == (LoadCmpBlocks.size() - 1))
19621961
? EndBlock
19631962
: LoadCmpBlocks[Index + 1];
1964-
// Early exit branch if difference found to ResultBlock, otherwise continue to
1965-
// next LoadCmpBlock or EndBlock.
1963+
// Early exit branch if difference found to ResultBlock. Otherwise, continue
1964+
// to next LoadCmpBlock or EndBlock.
19661965
BranchInst *CmpBr = BranchInst::Create(ResBlock.BB, NextBB, Cmp);
19671966
Builder.Insert(CmpBr);
19681967

19691968
// Add a phi edge for the last LoadCmpBlock to Endblock with a value of 0
19701969
// since early exit to ResultBlock was not taken (no difference was found in
1971-
// any of the bytes)
1970+
// any of the bytes).
19721971
if (Index == LoadCmpBlocks.size() - 1) {
19731972
Value *Zero = ConstantInt::get(Type::getInt32Ty(CI->getContext()), 0);
19741973
PhiRes->addIncoming(Zero, LoadCmpBlocks[Index]);
@@ -2048,8 +2047,8 @@ void MemCmpExpansion::setupEndBlockPHINodes() {
20482047
Value *MemCmpExpansion::getMemCmpExpansionZeroCase(unsigned Size,
20492048
bool IsLittleEndian) {
20502049
unsigned NumBytesProcessed = 0;
2051-
// This loop populates each of the LoadCmpBlocks with IR sequence to handle
2052-
// multiple loads per block
2050+
// This loop populates each of the LoadCmpBlocks with the IR sequence to
2051+
// handle multiple loads per block.
20532052
for (unsigned i = 0; i < NumBlocks; ++i) {
20542053
emitLoadCompareBlockMultipleLoads(i, Size, NumBytesProcessed);
20552054
}
@@ -2074,7 +2073,7 @@ Value *MemCmpExpansion::getMemCmpExpansion(bool IsLittleEndian) {
20742073

20752074
unsigned Index = 0;
20762075
// This loop calls emitLoadCompareBlock for comparing SizeVal bytes of the two
2077-
// memcmp source. It starts with loading using the maximum load size set by
2076+
// memcmp sources. It starts with loading using the maximum load size set by
20782077
// the target. It processes any remaining bytes using a load size which is the
20792078
// next smallest power of 2.
20802079
while (NumBytesToBeProcessed) {
@@ -2084,13 +2083,13 @@ Value *MemCmpExpansion::getMemCmpExpansion(bool IsLittleEndian) {
20842083
NumBytesToBeProcessed = NumBytesToBeProcessed % LoadSize;
20852084

20862085
// For each NumBlocks, populate the instruction sequence for loading and
2087-
// comparing LoadSize bytes
2086+
// comparing LoadSize bytes.
20882087
while (NumBlocks--) {
20892088
emitLoadCompareBlock(Index, LoadSize, GEPIndex, IsLittleEndian);
20902089
Index++;
20912090
GEPIndex++;
20922091
}
2093-
// Get the next LoadSize to use
2092+
// Get the next LoadSize to use.
20942093
LoadSize = LoadSize / 2;
20952094
}
20962095

@@ -2101,7 +2100,7 @@ Value *MemCmpExpansion::getMemCmpExpansion(bool IsLittleEndian) {
21012100
// This function checks to see if an expansion of memcmp can be generated.
21022101
// It checks for constant compare size that is less than the max inline size.
21032102
// If an expansion cannot occur, returns false to leave as a library call.
2104-
// Otherwise, the library call is replaced wtih new IR instruction sequence.
2103+
// Otherwise, the library call is replaced with a new IR instruction sequence.
21052104
/// We want to transform:
21062105
/// %call = call signext i32 @memcmp(i8* %0, i8* %1, i64 15)
21072106
/// To:
@@ -2176,25 +2175,24 @@ static bool expandMemCmp(CallInst *CI, const TargetTransformInfo *TTI,
21762175
NumMemCmpCalls++;
21772176
IRBuilder<> Builder(CI->getContext());
21782177

2179-
// TTI call to check if target would like to expand memcmp and get the
2180-
// MaxLoadSize
2178+
// TTI call to check if target would like to expand memcmp. Also, get the
2179+
// MaxLoadSize.
21812180
unsigned MaxLoadSize;
21822181
if (!TTI->expandMemCmp(CI, MaxLoadSize))
21832182
return false;
21842183

2185-
// Early exit from expansion if -Oz
2186-
if (CI->getParent()->getParent()->optForMinSize()) {
2184+
// Early exit from expansion if -Oz.
2185+
if (CI->getParent()->getParent()->optForMinSize())
21872186
return false;
2188-
}
21892187

2190-
// Early exit from expansion if size is not a constant
2188+
// Early exit from expansion if size is not a constant.
21912189
ConstantInt *SizeCast = dyn_cast<ConstantInt>(CI->getArgOperand(2));
21922190
if (!SizeCast) {
21932191
NumMemCmpNotConstant++;
21942192
return false;
21952193
}
21962194

2197-
// Early exit from expansion if size greater than max bytes to load
2195+
// Early exit from expansion if size greater than max bytes to load.
21982196
uint64_t SizeVal = SizeCast->getZExtValue();
21992197

22002198
unsigned NumLoads = 0;
@@ -2214,14 +2212,14 @@ static bool expandMemCmp(CallInst *CI, const TargetTransformInfo *TTI,
22142212

22152213
NumMemCmpInlined++;
22162214

2217-
// MemCmpHelper object, creates and sets up basic blocks required for
2218-
// expanding memcmp with size SizeVal
2215+
// MemCmpHelper object creates and sets up basic blocks required for
2216+
// expanding memcmp with size SizeVal.
22192217
unsigned NumLoadsPerBlock = MemCmpNumLoadsPerBlock;
22202218
MemCmpExpansion MemCmpHelper(CI, MaxLoadSize, NumLoadsPerBlock);
22212219

22222220
Value *Res = MemCmpHelper.getMemCmpExpansion(DL->isLittleEndian());
22232221

2224-
// Replace call with result of expansion and erarse call.
2222+
// Replace call with result of expansion and erase call.
22252223
CI->replaceAllUsesWith(Res);
22262224
CI->eraseFromParent();
22272225

0 commit comments

Comments
 (0)