@@ -295,31 +295,6 @@ static void deleteDeadInstruction(Instruction *I) {
295
295
I->eraseFromParent ();
296
296
}
297
297
298
- namespace {
299
- class ExpandedValuesCleaner {
300
- SCEVExpander &Expander;
301
- TargetLibraryInfo *TLI;
302
- SmallVector<Value *, 4 > ExpandedValues;
303
- bool Commit = false ;
304
-
305
- public:
306
- ExpandedValuesCleaner (SCEVExpander &Expander, TargetLibraryInfo *TLI)
307
- : Expander(Expander), TLI(TLI) {}
308
-
309
- void add (Value *V) { ExpandedValues.push_back (V); }
310
-
311
- void commit () { Commit = true ; }
312
-
313
- ~ExpandedValuesCleaner () {
314
- if (!Commit) {
315
- Expander.clear ();
316
- for (auto *V : ExpandedValues)
317
- RecursivelyDeleteTriviallyDeadInstructions (V, TLI);
318
- }
319
- }
320
- };
321
- } // namespace
322
-
323
298
// ===----------------------------------------------------------------------===//
324
299
//
325
300
// Implementation of LoopIdiomRecognize
@@ -933,7 +908,7 @@ bool LoopIdiomRecognize::processLoopStridedStore(
933
908
BasicBlock *Preheader = CurLoop->getLoopPreheader ();
934
909
IRBuilder<> Builder (Preheader->getTerminator ());
935
910
SCEVExpander Expander (*SE, *DL, " loop-idiom" );
936
- ExpandedValuesCleaner EVC (Expander, TLI );
911
+ SCEVExpanderCleaner ExpCleaner (Expander, *DT );
937
912
938
913
Type *DestInt8PtrTy = Builder.getInt8PtrTy (DestAS);
939
914
Type *IntIdxTy = DL->getIndexType (DestPtr->getType ());
@@ -956,7 +931,6 @@ bool LoopIdiomRecognize::processLoopStridedStore(
956
931
// base pointer and checking the region.
957
932
Value *BasePtr =
958
933
Expander.expandCodeFor (Start, DestInt8PtrTy, Preheader->getTerminator ());
959
- EVC.add (BasePtr);
960
934
961
935
// From here on out, conservatively report to the pass manager that we've
962
936
// changed the IR, even if we later clean up these added instructions. There
@@ -1041,7 +1015,7 @@ bool LoopIdiomRecognize::processLoopStridedStore(
1041
1015
if (MSSAU && VerifyMemorySSA)
1042
1016
MSSAU->getMemorySSA ()->verifyMemorySSA ();
1043
1017
++NumMemSet;
1044
- EVC. commit ();
1018
+ ExpCleaner. markResultUsed ();
1045
1019
return true ;
1046
1020
}
1047
1021
@@ -1075,7 +1049,7 @@ bool LoopIdiomRecognize::processLoopStoreOfLoopLoad(StoreInst *SI,
1075
1049
IRBuilder<> Builder (Preheader->getTerminator ());
1076
1050
SCEVExpander Expander (*SE, *DL, " loop-idiom" );
1077
1051
1078
- ExpandedValuesCleaner EVC (Expander, TLI );
1052
+ SCEVExpanderCleaner ExpCleaner (Expander, *DT );
1079
1053
1080
1054
bool Changed = false ;
1081
1055
const SCEV *StrStart = StoreEv->getStart ();
@@ -1094,7 +1068,6 @@ bool LoopIdiomRecognize::processLoopStoreOfLoopLoad(StoreInst *SI,
1094
1068
// checking everything.
1095
1069
Value *StoreBasePtr = Expander.expandCodeFor (
1096
1070
StrStart, Builder.getInt8PtrTy (StrAS), Preheader->getTerminator ());
1097
- EVC.add (StoreBasePtr);
1098
1071
1099
1072
// From here on out, conservatively report to the pass manager that we've
1100
1073
// changed the IR, even if we later clean up these added instructions. There
@@ -1122,7 +1095,6 @@ bool LoopIdiomRecognize::processLoopStoreOfLoopLoad(StoreInst *SI,
1122
1095
// mutated by the loop.
1123
1096
Value *LoadBasePtr = Expander.expandCodeFor (
1124
1097
LdStart, Builder.getInt8PtrTy (LdAS), Preheader->getTerminator ());
1125
- EVC.add (LoadBasePtr);
1126
1098
1127
1099
if (mayLoopAccessLocation (LoadBasePtr, ModRefInfo::Mod, CurLoop, BECount,
1128
1100
StoreSize, *AA, Stores))
@@ -1138,7 +1110,6 @@ bool LoopIdiomRecognize::processLoopStoreOfLoopLoad(StoreInst *SI,
1138
1110
1139
1111
Value *NumBytes =
1140
1112
Expander.expandCodeFor (NumBytesS, IntIdxTy, Preheader->getTerminator ());
1141
- EVC.add (NumBytes);
1142
1113
1143
1114
CallInst *NewCall = nullptr ;
1144
1115
// Check whether to generate an unordered atomic memcpy:
@@ -1198,7 +1169,7 @@ bool LoopIdiomRecognize::processLoopStoreOfLoopLoad(StoreInst *SI,
1198
1169
if (MSSAU && VerifyMemorySSA)
1199
1170
MSSAU->getMemorySSA ()->verifyMemorySSA ();
1200
1171
++NumMemCpy;
1201
- EVC. commit ();
1172
+ ExpCleaner. markResultUsed ();
1202
1173
return true ;
1203
1174
}
1204
1175
0 commit comments