@@ -73,22 +73,28 @@ ArrayRef<Instruction *> SeedBundle::getSlice(unsigned StartIdx,
7373}
7474
7575template <typename LoadOrStoreT>
76- SeedContainer::KeyT SeedContainer::getKey (LoadOrStoreT *LSI) const {
76+ SeedContainer::KeyT SeedContainer::getKey (LoadOrStoreT *LSI,
77+ bool AllowDiffTypes) const {
7778 assert ((isa<LoadInst>(LSI) || isa<StoreInst>(LSI)) &&
7879 " Expected Load or Store!" );
7980 Value *Ptr = Utils::getMemInstructionBase (LSI);
8081 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+ }
8490 return {Ptr, Ty, Op};
8591}
8692
8793// Explicit instantiations
8894template SeedContainer::KeyT
89- SeedContainer::getKey<LoadInst>(LoadInst *LSI) const ;
95+ SeedContainer::getKey<LoadInst>(LoadInst *LSI, bool AllowDiffTypes ) const ;
9096template SeedContainer::KeyT
91- SeedContainer::getKey<StoreInst>(StoreInst *LSI) const ;
97+ SeedContainer::getKey<StoreInst>(StoreInst *LSI, bool AllowDiffTypes ) const ;
9298
9399bool SeedContainer::erase (Instruction *I) {
94100 assert ((isa<LoadInst>(I) || isa<StoreInst>(I)) && " Expected Load or Store!" );
@@ -100,9 +106,10 @@ bool SeedContainer::erase(Instruction *I) {
100106 return true ;
101107}
102108
103- template <typename LoadOrStoreT> void SeedContainer::insert (LoadOrStoreT *LSI) {
109+ template <typename LoadOrStoreT>
110+ void SeedContainer::insert (LoadOrStoreT *LSI, bool AllowDiffTypes) {
104111 // 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 )];
106113 // Fill this vector of bundles front to back so that only the last bundle in
107114 // the vector may have available space. This avoids iteration to find one with
108115 // space.
@@ -115,9 +122,10 @@ template <typename LoadOrStoreT> void SeedContainer::insert(LoadOrStoreT *LSI) {
115122}
116123
117124// 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 *,
126+ bool );
127+ template LLVM_EXPORT_TEMPLATE void SeedContainer::insert<StoreInst>(StoreInst *,
128+ bool );
121129
122130#ifndef NDEBUG
123131void SeedContainer::print (raw_ostream &OS) const {
@@ -158,7 +166,8 @@ template bool isValidMemSeed<LoadInst>(LoadInst *LSI);
158166template bool isValidMemSeed<StoreInst>(StoreInst *LSI);
159167
160168SeedCollector::SeedCollector (BasicBlock *BB, ScalarEvolution &SE,
161- bool CollectStores, bool CollectLoads)
169+ bool CollectStores, bool CollectLoads,
170+ bool AllowDiffTypes)
162171 : StoreSeeds(SE), LoadSeeds(SE), Ctx(BB->getContext ()) {
163172
164173 if (!CollectStores && !CollectLoads)
@@ -175,10 +184,10 @@ SeedCollector::SeedCollector(BasicBlock *BB, ScalarEvolution &SE,
175184 for (auto &I : *BB) {
176185 if (StoreInst *SI = dyn_cast<StoreInst>(&I))
177186 if (CollectStores && isValidMemSeed (SI))
178- StoreSeeds.insert (SI);
187+ StoreSeeds.insert (SI, AllowDiffTypes );
179188 if (LoadInst *LI = dyn_cast<LoadInst>(&I))
180189 if (CollectLoads && isValidMemSeed (LI))
181- LoadSeeds.insert (LI);
190+ LoadSeeds.insert (LI, AllowDiffTypes );
182191 // Cap compilation time.
183192 if (totalNumSeedGroups () > SeedGroupsLimit)
184193 break ;
0 commit comments