Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit ff889a6

Browse files
committed
[GVN] Address review comments for D18662
As suggested by Chandler in his review comments for D18662, this follow-on patch renames some variables in GetLoadValueForLoad and CoerceAvailableValueToLoadType to hopefully make it more obvious which variables hold value sizes and which hold load/store sizes. No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265687 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent fb9ead0 commit ff889a6

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lib/Transforms/Scalar/GVN.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -725,11 +725,11 @@ static Value *CoerceAvailableValueToLoadType(Value *StoredVal, Type *LoadedTy,
725725
// If this is already the right type, just return it.
726726
Type *StoredValTy = StoredVal->getType();
727727

728-
uint64_t StoreSize = DL.getTypeSizeInBits(StoredValTy);
729-
uint64_t LoadSize = DL.getTypeSizeInBits(LoadedTy);
728+
uint64_t StoredValSize = DL.getTypeSizeInBits(StoredValTy);
729+
uint64_t LoadedValSize = DL.getTypeSizeInBits(LoadedTy);
730730

731731
// If the store and reload are the same size, we can always reuse it.
732-
if (StoreSize == LoadSize) {
732+
if (StoredValSize == LoadedValSize) {
733733
// Pointer to Pointer -> use bitcast.
734734
if (StoredValTy->getScalarType()->isPointerTy() &&
735735
LoadedTy->getScalarType()->isPointerTy())
@@ -758,7 +758,8 @@ static Value *CoerceAvailableValueToLoadType(Value *StoredVal, Type *LoadedTy,
758758
// If the loaded value is smaller than the available value, then we can
759759
// extract out a piece from it. If the available value is too small, then we
760760
// can't do anything.
761-
assert(StoreSize >= LoadSize && "CanCoerceMustAliasedValueToLoad fail");
761+
assert(StoredValSize >= LoadedValSize &&
762+
"CanCoerceMustAliasedValueToLoad fail");
762763

763764
// Convert source pointers to integers, which can be manipulated.
764765
if (StoredValTy->getScalarType()->isPointerTy()) {
@@ -768,7 +769,7 @@ static Value *CoerceAvailableValueToLoadType(Value *StoredVal, Type *LoadedTy,
768769

769770
// Convert vectors and fp to integer, which can be manipulated.
770771
if (!StoredValTy->isIntegerTy()) {
771-
StoredValTy = IntegerType::get(StoredValTy->getContext(), StoreSize);
772+
StoredValTy = IntegerType::get(StoredValTy->getContext(), StoredValSize);
772773
StoredVal = IRB.CreateBitCast(StoredVal, StoredValTy);
773774
}
774775

@@ -781,7 +782,7 @@ static Value *CoerceAvailableValueToLoadType(Value *StoredVal, Type *LoadedTy,
781782
}
782783

783784
// Truncate the integer to the right size now.
784-
Type *NewIntTy = IntegerType::get(StoredValTy->getContext(), LoadSize);
785+
Type *NewIntTy = IntegerType::get(StoredValTy->getContext(), LoadedValSize);
785786
StoredVal = IRB.CreateTrunc(StoredVal, NewIntTy, "trunc");
786787

787788
if (LoadedTy == NewIntTy)
@@ -1024,9 +1025,9 @@ static Value *GetLoadValueForLoad(LoadInst *SrcVal, unsigned Offset,
10241025
const DataLayout &DL = SrcVal->getModule()->getDataLayout();
10251026
// If Offset+LoadTy exceeds the size of SrcVal, then we must be wanting to
10261027
// widen SrcVal out to a larger load.
1027-
unsigned SrcValSize = DL.getTypeStoreSize(SrcVal->getType());
1028+
unsigned SrcValStoreSize = DL.getTypeStoreSize(SrcVal->getType());
10281029
unsigned LoadSize = DL.getTypeStoreSize(LoadTy);
1029-
if (Offset+LoadSize > SrcValSize) {
1030+
if (Offset+LoadSize > SrcValStoreSize) {
10301031
assert(SrcVal->isSimple() && "Cannot widen volatile/atomic load!");
10311032
assert(SrcVal->getType()->isIntegerTy() && "Can't widen non-integer load");
10321033
// If we have a load/load clobber an DepLI can be widened to cover this
@@ -1058,7 +1059,7 @@ static Value *GetLoadValueForLoad(LoadInst *SrcVal, unsigned Offset,
10581059
// system, we need to shift down to get the relevant bits.
10591060
Value *RV = NewLoad;
10601061
if (DL.isBigEndian())
1061-
RV = Builder.CreateLShr(RV, (NewLoadSize - SrcValSize) * 8);
1062+
RV = Builder.CreateLShr(RV, (NewLoadSize - SrcValStoreSize) * 8);
10621063
RV = Builder.CreateTrunc(RV, SrcVal->getType());
10631064
SrcVal->replaceAllUsesWith(RV);
10641065

0 commit comments

Comments
 (0)