[polly] r252941 - Consistenly use getTypeAllocSize for size estimation.
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 12 12:15:09 PST 2015
Author: jdoerfert
Date: Thu Nov 12 14:15:08 2015
New Revision: 252941
URL: http://llvm.org/viewvc/llvm-project?rev=252941&view=rev
Log:
Consistenly use getTypeAllocSize for size estimation.
Only when we check for wrapping we want to use the store size, for all
other cases we use the alloc size now.
Suggested by: Tobias Grosser <tobias at grosser.es>
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Analysis/ScopInfo.cpp
polly/trunk/test/ScopInfo/pointer-used-as-base-pointer-and-scalar-read.ll
polly/trunk/test/ScopInfo/same-base-address-scalar-and-array.ll
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=252941&r1=252940&r2=252941&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Thu Nov 12 14:15:08 2015
@@ -115,10 +115,11 @@ public:
/// @param IslCtx The isl context used to create the base pointer id.
/// @param DimensionSizes A vector containing the size of each dimension.
/// @param Kind The kind of the array object.
+ /// @param DL The data layout of the module.
/// @param S The scop this array object belongs to.
ScopArrayInfo(Value *BasePtr, Type *ElementType, isl_ctx *IslCtx,
ArrayRef<const SCEV *> DimensionSizes, enum ARRAYKIND Kind,
- Scop *S);
+ const DataLayout &DL, Scop *S);
/// @brief Update the sizes of the ScopArrayInfo object.
///
@@ -246,6 +247,9 @@ private:
/// We distinguish between SCALAR, PHI and ARRAY objects.
enum ARRAYKIND Kind;
+ /// @brief The data layout of the module.
+ const DataLayout &DL;
+
/// @brief The scop this SAI object belongs to.
Scop &S;
};
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=252941&r1=252940&r2=252941&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Thu Nov 12 14:15:08 2015
@@ -164,8 +164,8 @@ static const ScopArrayInfo *identifyBase
ScopArrayInfo::ScopArrayInfo(Value *BasePtr, Type *ElementType, isl_ctx *Ctx,
ArrayRef<const SCEV *> Sizes, enum ARRAYKIND Kind,
- Scop *S)
- : BasePtr(BasePtr), ElementType(ElementType), Kind(Kind), S(*S) {
+ const DataLayout &DL, Scop *S)
+ : BasePtr(BasePtr), ElementType(ElementType), Kind(Kind), DL(DL), S(*S) {
std::string BasePtrName =
getIslCompatibleName("MemRef_", BasePtr, Kind == KIND_PHI ? "__phi" : "");
Id = isl_id_alloc(Ctx, BasePtrName.c_str(), this);
@@ -216,7 +216,7 @@ ScopArrayInfo::~ScopArrayInfo() {
std::string ScopArrayInfo::getName() const { return isl_id_get_name(Id); }
int ScopArrayInfo::getElemSizeInBytes() const {
- return ElementType->getPrimitiveSizeInBits() / 8;
+ return DL.getTypeAllocSize(ElementType);
}
isl_id *ScopArrayInfo::getBasePtrId() const { return isl_id_copy(Id); }
@@ -2863,8 +2863,9 @@ Scop::getOrCreateScopArrayInfo(Value *Ba
ScopArrayInfo::ARRAYKIND Kind) {
auto &SAI = ScopArrayInfoMap[std::make_pair(BasePtr, Kind)];
if (!SAI) {
- SAI.reset(
- new ScopArrayInfo(BasePtr, AccessType, getIslCtx(), Sizes, Kind, this));
+ auto &DL = getRegion().getEntry()->getModule()->getDataLayout();
+ SAI.reset(new ScopArrayInfo(BasePtr, AccessType, getIslCtx(), Sizes, Kind,
+ DL, this));
} else {
// In case of mismatching array sizes, we bail out by setting the run-time
// context to false.
@@ -3573,13 +3574,13 @@ void ScopInfo::buildMemoryAccess(
if (LoadInst *Load = dyn_cast<LoadInst>(Inst)) {
SizeType = Load->getType();
- Size = TD->getTypeStoreSize(SizeType);
+ Size = TD->getTypeAllocSize(SizeType);
Type = MemoryAccess::READ;
Val = Load;
} else {
StoreInst *Store = cast<StoreInst>(Inst);
SizeType = Store->getValueOperand()->getType();
- Size = TD->getTypeStoreSize(SizeType);
+ Size = TD->getTypeAllocSize(SizeType);
Type = MemoryAccess::MUST_WRITE;
Val = Store->getValueOperand();
}
Modified: polly/trunk/test/ScopInfo/pointer-used-as-base-pointer-and-scalar-read.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/pointer-used-as-base-pointer-and-scalar-read.ll?rev=252941&r1=252940&r2=252941&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/pointer-used-as-base-pointer-and-scalar-read.ll (original)
+++ polly/trunk/test/ScopInfo/pointer-used-as-base-pointer-and-scalar-read.ll Thu Nov 12 14:15:08 2015
@@ -6,17 +6,17 @@
; CHECK: Arrays {
; CHECK: float MemRef_A[*]; // Element size 4
-; CHECK: float* MemRef_A; // Element size 0
-; CHECK: float* MemRef_x__phi; // Element size 0
-; CHECK: float* MemRef_B; // Element size 0
-; CHECK: float* MemRef_C[*]; // Element size 0
+; CHECK: float* MemRef_A; // Element size 8
+; CHECK: float* MemRef_x__phi; // Element size 8
+; CHECK: float* MemRef_B; // Element size 8
+; CHECK: float* MemRef_C[*]; // Element size 8
; CHECK: }
; CHECK: Arrays (Bounds as pw_affs) {
; CHECK: float MemRef_A[*]; // Element size 4
-; CHECK: float* MemRef_A; // Element size 0
-; CHECK: float* MemRef_x__phi; // Element size 0
-; CHECK: float* MemRef_B; // Element size 0
-; CHECK: float* MemRef_C[*]; // Element size 0
+; CHECK: float* MemRef_A; // Element size 8
+; CHECK: float* MemRef_x__phi; // Element size 8
+; CHECK: float* MemRef_B; // Element size 8
+; CHECK: float* MemRef_C[*]; // Element size 8
; CHECK: }
; CHECK: Alias Groups (0):
; CHECK: n/a
Modified: polly/trunk/test/ScopInfo/same-base-address-scalar-and-array.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/same-base-address-scalar-and-array.ll?rev=252941&r1=252940&r2=252941&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/same-base-address-scalar-and-array.ll (original)
+++ polly/trunk/test/ScopInfo/same-base-address-scalar-and-array.ll Thu Nov 12 14:15:08 2015
@@ -4,8 +4,8 @@
; as it is used as a memory base pointer (%0) but also as a scalar (%out.addr.0.lcssa).
;
; CHECK: Arrays {
-; CHECK-NEXT: float* MemRef_out; // Element size 0
-; CHECK-NEXT: float* MemRef_out_addr_0_lcssa; // Element size 0
+; CHECK-NEXT: float* MemRef_out; // Element size 8
+; CHECK-NEXT: float* MemRef_out_addr_0_lcssa; // Element size 8
; CHECK-NEXT: float MemRef_out[*]; // Element size 4
; CHECK-NEXT: }
;
More information about the llvm-commits
mailing list