@@ -73,22 +73,28 @@ ArrayRef<Instruction *> SeedBundle::getSlice(unsigned StartIdx,
73
73
}
74
74
75
75
template <typename LoadOrStoreT>
76
- SeedContainer::KeyT SeedContainer::getKey (LoadOrStoreT *LSI) const {
76
+ SeedContainer::KeyT SeedContainer::getKey (LoadOrStoreT *LSI,
77
+ bool AllowDiffTypes) const {
77
78
assert ((isa<LoadInst>(LSI) || isa<StoreInst>(LSI)) &&
78
79
" Expected Load or Store!" );
79
80
Value *Ptr = Utils::getMemInstructionBase (LSI);
80
81
Instruction::Opcode Op = LSI->getOpcode ();
81
- Type *Ty = Utils::getExpectedType (LSI);
82
- if (auto *VTy = dyn_cast<VectorType>(Ty))
83
- Ty = VTy->getElementType ();
82
+ Type *Ty;
83
+ if (AllowDiffTypes) {
84
+ Ty = nullptr ;
85
+ } else {
86
+ Ty = Utils::getExpectedType (LSI);
87
+ if (auto *VTy = dyn_cast<VectorType>(Ty))
88
+ Ty = VTy->getElementType ();
89
+ }
84
90
return {Ptr, Ty, Op};
85
91
}
86
92
87
93
// Explicit instantiations
88
94
template SeedContainer::KeyT
89
- SeedContainer::getKey<LoadInst>(LoadInst *LSI) const ;
95
+ SeedContainer::getKey<LoadInst>(LoadInst *LSI, bool AllowDiffTypes ) const ;
90
96
template SeedContainer::KeyT
91
- SeedContainer::getKey<StoreInst>(StoreInst *LSI) const ;
97
+ SeedContainer::getKey<StoreInst>(StoreInst *LSI, bool AllowDiffTypes ) const ;
92
98
93
99
bool SeedContainer::erase (Instruction *I) {
94
100
assert ((isa<LoadInst>(I) || isa<StoreInst>(I)) && " Expected Load or Store!" );
@@ -100,9 +106,10 @@ bool SeedContainer::erase(Instruction *I) {
100
106
return true ;
101
107
}
102
108
103
- template <typename LoadOrStoreT> void SeedContainer::insert (LoadOrStoreT *LSI) {
109
+ template <typename LoadOrStoreT>
110
+ void SeedContainer::insert (LoadOrStoreT *LSI, bool AllowDiffTypes) {
104
111
// Find the bundle containing seeds for this symbol and type-of-access.
105
- auto &BundleVec = Bundles[getKey (LSI)];
112
+ auto &BundleVec = Bundles[getKey (LSI, AllowDiffTypes )];
106
113
// Fill this vector of bundles front to back so that only the last bundle in
107
114
// the vector may have available space. This avoids iteration to find one with
108
115
// space.
@@ -115,9 +122,9 @@ template <typename LoadOrStoreT> void SeedContainer::insert(LoadOrStoreT *LSI) {
115
122
}
116
123
117
124
// Explicit instantiations
118
- template LLVM_EXPORT_TEMPLATE void SeedContainer::insert<LoadInst>(LoadInst *);
119
- template LLVM_EXPORT_TEMPLATE void
120
- SeedContainer::insert<StoreInst>(StoreInst * );
125
+ template LLVM_EXPORT_TEMPLATE void SeedContainer::insert<LoadInst>(LoadInst *, bool );
126
+ template LLVM_EXPORT_TEMPLATE void SeedContainer::insert<StoreInst>(StoreInst *,
127
+ bool );
121
128
122
129
#ifndef NDEBUG
123
130
void SeedContainer::print (raw_ostream &OS) const {
@@ -158,7 +165,8 @@ template bool isValidMemSeed<LoadInst>(LoadInst *LSI);
158
165
template bool isValidMemSeed<StoreInst>(StoreInst *LSI);
159
166
160
167
SeedCollector::SeedCollector (BasicBlock *BB, ScalarEvolution &SE,
161
- bool CollectStores, bool CollectLoads)
168
+ bool CollectStores, bool CollectLoads,
169
+ bool AllowDiffTypes)
162
170
: StoreSeeds(SE), LoadSeeds(SE), Ctx(BB->getContext ()) {
163
171
164
172
if (!CollectStores && !CollectLoads)
@@ -175,10 +183,10 @@ SeedCollector::SeedCollector(BasicBlock *BB, ScalarEvolution &SE,
175
183
for (auto &I : *BB) {
176
184
if (StoreInst *SI = dyn_cast<StoreInst>(&I))
177
185
if (CollectStores && isValidMemSeed (SI))
178
- StoreSeeds.insert (SI);
186
+ StoreSeeds.insert (SI, AllowDiffTypes );
179
187
if (LoadInst *LI = dyn_cast<LoadInst>(&I))
180
188
if (CollectLoads && isValidMemSeed (LI))
181
- LoadSeeds.insert (LI);
189
+ LoadSeeds.insert (LI, AllowDiffTypes );
182
190
// Cap compilation time.
183
191
if (totalNumSeedGroups () > SeedGroupsLimit)
184
192
break ;
0 commit comments