@@ -4030,16 +4030,13 @@ bool PhiNodeSetIterator::operator!=(const PhiNodeSetIterator &RHS) const {
40304030// / if it is simplified.
40314031class SimplificationTracker {
40324032 DenseMap<Value *, Value *> Storage;
4033- const SimplifyQuery &SQ;
40344033 // Tracks newly created Phi nodes. The elements are iterated by insertion
40354034 // order.
40364035 PhiNodeSet AllPhiNodes;
40374036 // Tracks newly created Select nodes.
40384037 SmallPtrSet<SelectInst *, 32 > AllSelectNodes;
40394038
40404039public:
4041- SimplificationTracker (const SimplifyQuery &sq) : SQ(sq) {}
4042-
40434040 Value *Get (Value *V) {
40444041 do {
40454042 auto SV = Storage.find (V);
@@ -4049,30 +4046,6 @@ class SimplificationTracker {
40494046 } while (true );
40504047 }
40514048
4052- Value *Simplify (Value *Val) {
4053- SmallVector<Value *, 32 > WorkList;
4054- SmallPtrSet<Value *, 32 > Visited;
4055- WorkList.push_back (Val);
4056- while (!WorkList.empty ()) {
4057- auto *P = WorkList.pop_back_val ();
4058- if (!Visited.insert (P).second )
4059- continue ;
4060- if (auto *PI = dyn_cast<Instruction>(P))
4061- if (Value *V = simplifyInstruction (cast<Instruction>(PI), SQ)) {
4062- for (auto *U : PI->users ())
4063- WorkList.push_back (cast<Value>(U));
4064- Put (PI, V);
4065- PI->replaceAllUsesWith (V);
4066- if (auto *PHI = dyn_cast<PHINode>(PI))
4067- AllPhiNodes.erase (PHI);
4068- if (auto *Select = dyn_cast<SelectInst>(PI))
4069- AllSelectNodes.erase (Select);
4070- PI->eraseFromParent ();
4071- }
4072- }
4073- return Get (Val);
4074- }
4075-
40764049 void Put (Value *From, Value *To) { Storage.insert ({From, To}); }
40774050
40784051 void ReplacePhi (PHINode *From, PHINode *To) {
@@ -4133,8 +4106,7 @@ class AddressingModeCombiner {
41334106 // / Common Type for all different fields in addressing modes.
41344107 Type *CommonType = nullptr ;
41354108
4136- // / SimplifyQuery for simplifyInstruction utility.
4137- const SimplifyQuery &SQ;
4109+ const DataLayout &DL;
41384110
41394111 // / Original Address.
41404112 Value *Original;
@@ -4143,8 +4115,8 @@ class AddressingModeCombiner {
41434115 Value *CommonValue = nullptr ;
41444116
41454117public:
4146- AddressingModeCombiner (const SimplifyQuery &_SQ , Value *OriginalValue)
4147- : SQ(_SQ ), Original(OriginalValue) {}
4118+ AddressingModeCombiner (const DataLayout &DL , Value *OriginalValue)
4119+ : DL(DL ), Original(OriginalValue) {}
41484120
41494121 ~AddressingModeCombiner () { eraseCommonValueIfDead (); }
41504122
@@ -4256,7 +4228,7 @@ class AddressingModeCombiner {
42564228 // Keep track of keys where the value is null. We will need to replace it
42574229 // with constant null when we know the common type.
42584230 SmallVector<Value *, 2 > NullValue;
4259- Type *IntPtrTy = SQ. DL .getIntPtrType (AddrModes[0 ].OriginalValue ->getType ());
4231+ Type *IntPtrTy = DL.getIntPtrType (AddrModes[0 ].OriginalValue ->getType ());
42604232 for (auto &AM : AddrModes) {
42614233 Value *DV = AM.GetFieldAsValue (DifferentField, IntPtrTy);
42624234 if (DV) {
@@ -4306,7 +4278,7 @@ class AddressingModeCombiner {
43064278 // simplification is possible only if original phi/selects were not
43074279 // simplified yet.
43084280 // Using this mapping we can find the current value in AddrToBase.
4309- SimplificationTracker ST (SQ) ;
4281+ SimplificationTracker ST;
43104282
43114283 // First step, DFS to create PHI nodes for all intermediate blocks.
43124284 // Also fill traverse order for the second step.
@@ -4465,7 +4437,6 @@ class AddressingModeCombiner {
44654437 PHI->addIncoming (ST.Get (Map[PV]), B);
44664438 }
44674439 }
4468- Map[Current] = ST.Simplify (V);
44694440 }
44704441 }
44714442
@@ -5856,8 +5827,7 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
58565827 // the graph are compatible.
58575828 bool PhiOrSelectSeen = false ;
58585829 SmallVector<Instruction *, 16 > AddrModeInsts;
5859- const SimplifyQuery SQ (*DL, TLInfo);
5860- AddressingModeCombiner AddrModes (SQ, Addr);
5830+ AddressingModeCombiner AddrModes (*DL, Addr);
58615831 TypePromotionTransaction TPT (RemovedInsts);
58625832 TypePromotionTransaction::ConstRestorationPt LastKnownGood =
58635833 TPT.getRestorationPoint ();
0 commit comments