summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
diff options
context:
space:
mode:
authorJonas Paulsson <paulsson@linux.vnet.ibm.com>2017-11-28 14:44:32 +0000
committerJonas Paulsson <paulsson@linux.vnet.ibm.com>2017-11-28 14:44:32 +0000
commitf0ff20f1f01fb7c5323c1d89b5e0b19bec0e9e39 (patch)
treebe9db6d1dd1df7469862ffdf0461388f39a1f77a /llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
parentb843dc26e4bc0dd5e3ee85f93194773cacc152ea (diff)
downloadbcm5719-llvm-f0ff20f1f01fb7c5323c1d89b5e0b19bec0e9e39.tar.gz
bcm5719-llvm-f0ff20f1f01fb7c5323c1d89b5e0b19bec0e9e39.zip
Use getStoreSize() in various places instead of 'BitSize >> 3'.
This is needed for cases when the memory access is not as big as the width of the data type. For instance, storing i1 (1 bit) would be done in a byte (8 bits). Using 'BitSize >> 3' (or '/ 8') would e.g. give the memory access of an i1 a size of 0, which for instance makes alias analysis return NoAlias even when it shouldn't. There are no tests as this was done as a follow-up to the bugfix for the case where this was discovered (r318824). This handles more similar cases. Review: Björn Petterson https://reviews.llvm.org/D40339 llvm-svn: 319173
Diffstat (limited to 'llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp')
-rw-r--r--llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
index 2154a485dc6..25f101b4931 100644
--- a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
@@ -140,7 +140,6 @@ namespace {
bool runOnLoop(Loop *L, LPPassManager &LPM) override;
private:
- unsigned getStoreSizeInBytes(StoreInst *SI);
int getSCEVStride(const SCEVAddRecExpr *StoreEv);
bool isLegalStore(Loop *CurLoop, StoreInst *SI);
void collectStores(Loop *CurLoop, BasicBlock *BB,
@@ -1847,13 +1846,6 @@ bool PolynomialMultiplyRecognize::recognize() {
return true;
}
-unsigned HexagonLoopIdiomRecognize::getStoreSizeInBytes(StoreInst *SI) {
- uint64_t SizeInBits = DL->getTypeSizeInBits(SI->getValueOperand()->getType());
- assert(((SizeInBits & 7) || (SizeInBits >> 32) == 0) &&
- "Don't overflow unsigned.");
- return (unsigned)SizeInBits >> 3;
-}
-
int HexagonLoopIdiomRecognize::getSCEVStride(const SCEVAddRecExpr *S) {
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(S->getOperand(1)))
return SC->getAPInt().getSExtValue();
@@ -1885,7 +1877,7 @@ bool HexagonLoopIdiomRecognize::isLegalStore(Loop *CurLoop, StoreInst *SI) {
int Stride = getSCEVStride(StoreEv);
if (Stride == 0)
return false;
- unsigned StoreSize = getStoreSizeInBytes(SI);
+ unsigned StoreSize = DL->getTypeStoreSize(SI->getValueOperand()->getType());
if (StoreSize != unsigned(std::abs(Stride)))
return false;
@@ -1960,7 +1952,7 @@ bool HexagonLoopIdiomRecognize::processCopyingStore(Loop *CurLoop,
Value *StorePtr = SI->getPointerOperand();
auto *StoreEv = cast<SCEVAddRecExpr>(SE->getSCEV(StorePtr));
unsigned Stride = getSCEVStride(StoreEv);
- unsigned StoreSize = getStoreSizeInBytes(SI);
+ unsigned StoreSize = DL->getTypeStoreSize(SI->getValueOperand()->getType());
if (Stride != StoreSize)
return false;
OpenPOWER on IntegriCloud