// TODO: Remove this
static const unsigned TargetBaseAlign = 4;
-class Vectorizer {
- typedef SmallVector<Value *, 8> ValueList;
- typedef MapVector<Value *, ValueList> ValueListMap;
+typedef SmallVector<Value *, 8> ValueList;
+typedef MapVector<Value *, ValueList> ValueListMap;
+class Vectorizer {
Function &F;
AliasAnalysis &AA;
DominatorTree &DT;
TargetTransformInfo &TTI;
const DataLayout &DL;
IRBuilder<> Builder;
- ValueListMap StoreRefs;
- ValueListMap LoadRefs;
public:
Vectorizer(Function &F, AliasAnalysis &AA, DominatorTree &DT,
BasicBlock::iterator To);
/// Collects load and store instructions to vectorize.
- void collectInstructions(BasicBlock *BB);
+ std::pair<ValueListMap, ValueListMap> collectInstructions(BasicBlock *BB);
/// Processes the collected instructions, the \p Map. The elements of \p Map
/// should be all loads or all stores.
// Scan the blocks in the function in post order.
for (BasicBlock *BB : post_order(&F)) {
- collectInstructions(BB);
+ ValueListMap LoadRefs, StoreRefs;
+ std::tie(LoadRefs, StoreRefs) = collectInstructions(BB);
Changed |= vectorizeChains(LoadRefs);
Changed |= vectorizeChains(StoreRefs);
}
return Chain.size();
}
-void Vectorizer::collectInstructions(BasicBlock *BB) {
- LoadRefs.clear();
- StoreRefs.clear();
+std::pair<ValueListMap, ValueListMap>
+Vectorizer::collectInstructions(BasicBlock *BB) {
+ ValueListMap LoadRefs;
+ ValueListMap StoreRefs;
for (Instruction &I : *BB) {
if (!I.mayReadOrWriteMemory())
StoreRefs[ObjPtr].push_back(SI);
}
}
+
+ return {LoadRefs, StoreRefs};
}
bool Vectorizer::vectorizeChains(ValueListMap &Map) {