[llvm-commits] [llvm] r154089 - in /llvm/trunk: include/llvm/Transforms/Vectorize.h lib/Transforms/Vectorize/BBVectorize.cpp
Hongbin Zheng
etherzhhb at gmail.com
Thu Apr 5 01:05:16 PDT 2012
Author: ether
Date: Thu Apr 5 03:05:16 2012
New Revision: 154089
URL: http://llvm.org/viewvc/llvm-project?rev=154089&view=rev
Log:
Add the function "vectorizeBasicBlock" which allow users vectorize a
BasicBlock in other passes, e.g. we can call vectorizeBasicBlock in the
loop unroll pass right after the loop is unrolled.
Modified:
llvm/trunk/include/llvm/Transforms/Vectorize.h
llvm/trunk/lib/Transforms/Vectorize/BBVectorize.cpp
Modified: llvm/trunk/include/llvm/Transforms/Vectorize.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Vectorize.h?rev=154089&r1=154088&r2=154089&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Vectorize.h (original)
+++ llvm/trunk/include/llvm/Transforms/Vectorize.h Thu Apr 5 03:05:16 2012
@@ -16,7 +16,7 @@
#define LLVM_TRANSFORMS_VECTORIZE_H
namespace llvm {
-
+class BasicBlock;
class BasicBlockPass;
//===----------------------------------------------------------------------===//
@@ -25,6 +25,18 @@
//
BasicBlockPass *createBBVectorizePass();
+//===----------------------------------------------------------------------===//
+/// @brief Vectorize the BasicBlock.
+///
+/// @param BB The BasicBlock to be vectorized
+/// @param P The current running pass, should require AliasAnalysis and
+/// ScalarEvolution. After the vectorization, AliasAnalysis,
+/// ScalarEvolution and CFG are preserved.
+///
+/// @return True if the BB is changed, false otherwise.
+///
+bool vectorizeBasicBlock(Pass *P, BasicBlock &BB);
+
} // End llvm namespace
#endif
Modified: llvm/trunk/lib/Transforms/Vectorize/BBVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/BBVectorize.cpp?rev=154089&r1=154088&r2=154089&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/BBVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/BBVectorize.cpp Thu Apr 5 03:05:16 2012
@@ -144,6 +144,12 @@
initializeBBVectorizePass(*PassRegistry::getPassRegistry());
}
+ BBVectorize(Pass *P) : BasicBlockPass(ID) {
+ AA = &P->getAnalysis<AliasAnalysis>();
+ SE = &P->getAnalysis<ScalarEvolution>();
+ TD = P->getAnalysisIfAvailable<TargetData>();
+ }
+
typedef std::pair<Value *, Value *> ValuePair;
typedef std::pair<ValuePair, size_t> ValuePairWithDepth;
typedef std::pair<ValuePair, ValuePair> VPPair; // A ValuePair pair
@@ -280,11 +286,7 @@
Instruction *&InsertionPt,
Instruction *I, Instruction *J);
- virtual bool runOnBasicBlock(BasicBlock &BB) {
- AA = &getAnalysis<AliasAnalysis>();
- SE = &getAnalysis<ScalarEvolution>();
- TD = getAnalysisIfAvailable<TargetData>();
-
+ bool vectorizeBB(BasicBlock &BB) {
bool changed = false;
// Iterate a sufficient number of times to merge types of size 1 bit,
// then 2 bits, then 4, etc. up to half of the target vector width of the
@@ -304,6 +306,14 @@
return changed;
}
+ virtual bool runOnBasicBlock(BasicBlock &BB) {
+ AA = &getAnalysis<AliasAnalysis>();
+ SE = &getAnalysis<ScalarEvolution>();
+ TD = getAnalysisIfAvailable<TargetData>();
+
+ return vectorizeBB(BB);
+ }
+
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
BasicBlockPass::getAnalysisUsage(AU);
AU.addRequired<AliasAnalysis>();
@@ -1861,3 +1871,7 @@
return new BBVectorize();
}
+bool llvm::vectorizeBasicBlock(Pass *P, BasicBlock &BB) {
+ BBVectorize BBVectorizer(P);
+ return BBVectorizer.vectorizeBB(BB);
+}
More information about the llvm-commits
mailing list