[PATCH] Refactoring getStrideFromPointer & getGEPInductionOperand
Ashutosh Nema
ashutosh.nema at amd.com
Tue Mar 24 23:37:47 PDT 2015
Hi anemet, hfinkel, reames,
I like to reuse following two functions:
a) getStrideFromPointer b) getGEPInductionOperand
Found these are defined as static in LoopVectorizer.
I made these as a general purpose utility function.
Declared "getStrideFromPointer" under llvm namespace in LoopUtils.h
Declared "getGEPInductionOperand" under llvm namespace in VectorUtils.h
Updated their definition accordingly.
Requesting to review this change.
Thanks,
Ashutosh
REPOSITORY
rL LLVM
http://reviews.llvm.org/D8602
Files:
include/llvm/Transforms/Utils/LoopUtils.h
include/llvm/Transforms/Utils/VectorUtils.h
lib/Transforms/Vectorize/LoopVectorize.cpp
Index: include/llvm/Transforms/Utils/LoopUtils.h
===================================================================
--- include/llvm/Transforms/Utils/LoopUtils.h
+++ include/llvm/Transforms/Utils/LoopUtils.h
@@ -122,6 +122,12 @@
/// Updates safety information in LICMSafetyInfo argument.
void computeLICMSafetyInfo(LICMSafetyInfo *, Loop *);
+/// \brief Get the stride of a pointer access in a loop.
+/// Looks for symbolic strides "a[i*stride]". Returns the symbolic stride as a
+/// pointer to the Value, or null otherwise, It takes pointer, scalar evolution
+/// and loop pointer.
+Value * getStrideFromPointer(Value *Ptr, ScalarEvolution *SE, Loop *Lp);
+
}
#endif
Index: include/llvm/Transforms/Utils/VectorUtils.h
===================================================================
--- include/llvm/Transforms/Utils/VectorUtils.h
+++ include/llvm/Transforms/Utils/VectorUtils.h
@@ -200,6 +200,11 @@
return Intrinsic::not_intrinsic;
}
+/// \brief Find the operand of the GEP that should be checked for consecutive
+/// stores. This ignores trailing indices that have no effect on the final
+/// pointer.
+unsigned getGEPInductionOperand(const GetElementPtrInst *Gep);
+
} // llvm namespace
#endif
Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -93,6 +93,7 @@
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/VectorUtils.h"
+#include "llvm/Transforms/Utils/LoopUtils.h"
#include <algorithm>
#include <map>
#include <tuple>
@@ -1597,7 +1598,7 @@
/// \brief Find the operand of the GEP that should be checked for consecutive
/// stores. This ignores trailing indices that have no effect on the final
/// pointer.
-static unsigned getGEPInductionOperand(const GetElementPtrInst *Gep) {
+unsigned llvm::getGEPInductionOperand(const GetElementPtrInst *Gep) {
const DataLayout &DL = Gep->getModule()->getDataLayout();
unsigned LastOperand = Gep->getNumOperands() - 1;
unsigned GEPAllocSize = DL.getTypeAllocSize(
@@ -3867,7 +3868,7 @@
///\brief Get the stride of a pointer access in a loop.
/// Looks for symbolic strides "a[i*stride]". Returns the symbolic stride as a
/// pointer to the Value, or null otherwise.
-static Value *getStrideFromPointer(Value *Ptr, ScalarEvolution *SE, Loop *Lp) {
+Value *llvm::getStrideFromPointer(Value *Ptr, ScalarEvolution *SE, Loop *Lp) {
const PointerType *PtrTy = dyn_cast<PointerType>(Ptr->getType());
if (!PtrTy || PtrTy->isAggregateType())
return nullptr;
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8602.22629.patch
Type: text/x-patch
Size: 2690 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150325/14909f37/attachment.bin>
More information about the llvm-commits
mailing list