@@ -4076,16 +4076,13 @@ bool PhiNodeSetIterator::operator!=(const PhiNodeSetIterator &RHS) const {
40764076// / if it is simplified.
40774077class SimplificationTracker {
40784078 DenseMap<Value *, Value *> Storage;
4079- const SimplifyQuery &SQ;
40804079 // Tracks newly created Phi nodes. The elements are iterated by insertion
40814080 // order.
40824081 PhiNodeSet AllPhiNodes;
40834082 // Tracks newly created Select nodes.
40844083 SmallPtrSet<SelectInst *, 32 > AllSelectNodes;
40854084
40864085public:
4087- SimplificationTracker (const SimplifyQuery &sq) : SQ(sq) {}
4088-
40894086 Value *Get (Value *V) {
40904087 do {
40914088 auto SV = Storage.find (V);
@@ -4095,30 +4092,6 @@ class SimplificationTracker {
40954092 } while (true );
40964093 }
40974094
4098- Value *Simplify (Value *Val) {
4099- SmallVector<Value *, 32 > WorkList;
4100- SmallPtrSet<Value *, 32 > Visited;
4101- WorkList.push_back (Val);
4102- while (!WorkList.empty ()) {
4103- auto *P = WorkList.pop_back_val ();
4104- if (!Visited.insert (P).second )
4105- continue ;
4106- if (auto *PI = dyn_cast<Instruction>(P))
4107- if (Value *V = simplifyInstruction (cast<Instruction>(PI), SQ)) {
4108- for (auto *U : PI->users ())
4109- WorkList.push_back (cast<Value>(U));
4110- Put (PI, V);
4111- PI->replaceAllUsesWith (V);
4112- if (auto *PHI = dyn_cast<PHINode>(PI))
4113- AllPhiNodes.erase (PHI);
4114- if (auto *Select = dyn_cast<SelectInst>(PI))
4115- AllSelectNodes.erase (Select);
4116- PI->eraseFromParent ();
4117- }
4118- }
4119- return Get (Val);
4120- }
4121-
41224095 void Put (Value *From, Value *To) { Storage.insert ({From, To}); }
41234096
41244097 void ReplacePhi (PHINode *From, PHINode *To) {
@@ -4179,8 +4152,7 @@ class AddressingModeCombiner {
41794152 // / Common Type for all different fields in addressing modes.
41804153 Type *CommonType = nullptr ;
41814154
4182- // / SimplifyQuery for simplifyInstruction utility.
4183- const SimplifyQuery &SQ;
4155+ const DataLayout &DL;
41844156
41854157 // / Original Address.
41864158 Value *Original;
@@ -4189,8 +4161,8 @@ class AddressingModeCombiner {
41894161 Value *CommonValue = nullptr ;
41904162
41914163public:
4192- AddressingModeCombiner (const SimplifyQuery &_SQ , Value *OriginalValue)
4193- : SQ(_SQ ), Original(OriginalValue) {}
4164+ AddressingModeCombiner (const DataLayout &DL , Value *OriginalValue)
4165+ : DL(DL ), Original(OriginalValue) {}
41944166
41954167 ~AddressingModeCombiner () { eraseCommonValueIfDead (); }
41964168
@@ -4302,7 +4274,7 @@ class AddressingModeCombiner {
43024274 // Keep track of keys where the value is null. We will need to replace it
43034275 // with constant null when we know the common type.
43044276 SmallVector<Value *, 2 > NullValue;
4305- Type *IntPtrTy = SQ. DL .getIntPtrType (AddrModes[0 ].OriginalValue ->getType ());
4277+ Type *IntPtrTy = DL.getIntPtrType (AddrModes[0 ].OriginalValue ->getType ());
43064278 for (auto &AM : AddrModes) {
43074279 Value *DV = AM.GetFieldAsValue (DifferentField, IntPtrTy);
43084280 if (DV) {
@@ -4352,7 +4324,7 @@ class AddressingModeCombiner {
43524324 // simplification is possible only if original phi/selects were not
43534325 // simplified yet.
43544326 // Using this mapping we can find the current value in AddrToBase.
4355- SimplificationTracker ST (SQ) ;
4327+ SimplificationTracker ST;
43564328
43574329 // First step, DFS to create PHI nodes for all intermediate blocks.
43584330 // Also fill traverse order for the second step.
@@ -4511,7 +4483,6 @@ class AddressingModeCombiner {
45114483 PHI->addIncoming (ST.Get (Map[PV]), B);
45124484 }
45134485 }
4514- Map[Current] = ST.Simplify (V);
45154486 }
45164487 }
45174488
@@ -5902,8 +5873,7 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
59025873 // the graph are compatible.
59035874 bool PhiOrSelectSeen = false ;
59045875 SmallVector<Instruction *, 16 > AddrModeInsts;
5905- const SimplifyQuery SQ (*DL, TLInfo);
5906- AddressingModeCombiner AddrModes (SQ, Addr);
5876+ AddressingModeCombiner AddrModes (*DL, Addr);
59075877 TypePromotionTransaction TPT (RemovedInsts);
59085878 TypePromotionTransaction::ConstRestorationPt LastKnownGood =
59095879 TPT.getRestorationPoint ();
0 commit comments