Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 1 | //===- LoopStrengthReduce.cpp - Strength Reduce GEPs in Loops -------------===// |
Misha Brukman | b1c9317 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 2 | // |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Nate Begeman and is distributed under the |
| 6 | // University of Illinois Open Source License. See LICENSE.TXT for details. |
Misha Brukman | b1c9317 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 7 | // |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This pass performs a strength reduction on array references inside loops that |
| 11 | // have as one or more of their components the loop induction variable. This is |
| 12 | // accomplished by creating a new Value to hold the initial value of the array |
| 13 | // access for the first iteration, and then creating a new GEP instruction in |
| 14 | // the loop to increment the value by the appropriate amount. |
| 15 | // |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 16 | //===----------------------------------------------------------------------===// |
| 17 | |
| 18 | #include "llvm/Transforms/Scalar.h" |
| 19 | #include "llvm/Constants.h" |
| 20 | #include "llvm/Instructions.h" |
| 21 | #include "llvm/Type.h" |
Jeff Cohen | a2c59b7 | 2005-03-04 04:04:26 +0000 | [diff] [blame] | 22 | #include "llvm/DerivedTypes.h" |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 23 | #include "llvm/Analysis/Dominators.h" |
| 24 | #include "llvm/Analysis/LoopInfo.h" |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 25 | #include "llvm/Analysis/ScalarEvolutionExpander.h" |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 26 | #include "llvm/Support/CFG.h" |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 27 | #include "llvm/Support/GetElementPtrTypeIterator.h" |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 28 | #include "llvm/Transforms/Utils/Local.h" |
Jeff Cohen | a2c59b7 | 2005-03-04 04:04:26 +0000 | [diff] [blame] | 29 | #include "llvm/Target/TargetData.h" |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 30 | #include "llvm/ADT/Statistic.h" |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 31 | #include "llvm/Support/Debug.h" |
Jeff Cohen | c500991 | 2005-07-30 18:22:27 +0000 | [diff] [blame] | 32 | #include <algorithm> |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 33 | #include <set> |
| 34 | using namespace llvm; |
| 35 | |
| 36 | namespace { |
| 37 | Statistic<> NumReduced ("loop-reduce", "Number of GEPs strength reduced"); |
| 38 | |
Chris Lattner | d3874fa | 2005-03-06 21:58:22 +0000 | [diff] [blame] | 39 | class GEPCache { |
Jeff Cohen | be37fa0 | 2005-03-05 22:40:34 +0000 | [diff] [blame] | 40 | public: |
| 41 | GEPCache() : CachedPHINode(0), Map() {} |
| 42 | |
Chris Lattner | d3874fa | 2005-03-06 21:58:22 +0000 | [diff] [blame] | 43 | GEPCache *get(Value *v) { |
Jeff Cohen | be37fa0 | 2005-03-05 22:40:34 +0000 | [diff] [blame] | 44 | std::map<Value *, GEPCache>::iterator I = Map.find(v); |
| 45 | if (I == Map.end()) |
| 46 | I = Map.insert(std::pair<Value *, GEPCache>(v, GEPCache())).first; |
Chris Lattner | d3874fa | 2005-03-06 21:58:22 +0000 | [diff] [blame] | 47 | return &I->second; |
Jeff Cohen | be37fa0 | 2005-03-05 22:40:34 +0000 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | PHINode *CachedPHINode; |
| 51 | std::map<Value *, GEPCache> Map; |
| 52 | }; |
| 53 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 54 | struct IVUse { |
| 55 | /// Users - Keep track of all of the users of this stride as well as the |
| 56 | /// initial value. |
| 57 | std::vector<std::pair<SCEVHandle, Instruction*> > Users; |
| 58 | std::vector<Instruction *> UserOperands; |
| 59 | |
| 60 | void addUser(SCEVHandle &SH, Instruction *U, Instruction *V) { |
| 61 | Users.push_back(std::make_pair(SH, U)); |
| 62 | UserOperands.push_back(V); |
| 63 | } |
| 64 | }; |
| 65 | |
| 66 | |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 67 | class LoopStrengthReduce : public FunctionPass { |
| 68 | LoopInfo *LI; |
| 69 | DominatorSet *DS; |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 70 | ScalarEvolution *SE; |
| 71 | const TargetData *TD; |
| 72 | const Type *UIntPtrTy; |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 73 | bool Changed; |
Jeff Cohen | a2c59b7 | 2005-03-04 04:04:26 +0000 | [diff] [blame] | 74 | unsigned MaxTargetAMSize; |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 75 | |
| 76 | /// IVUsesByStride - Keep track of all uses of induction variables that we |
| 77 | /// are interested in. The key of the map is the stride of the access. |
| 78 | std::map<Value*, IVUse> IVUsesByStride; |
| 79 | |
| 80 | /// CastedBasePointers - As we need to lower getelementptr instructions, we |
| 81 | /// cast the pointer input to uintptr_t. This keeps track of the casted |
| 82 | /// values for the pointers we have processed so far. |
| 83 | std::map<Value*, Value*> CastedBasePointers; |
| 84 | |
| 85 | /// DeadInsts - Keep track of instructions we may have made dead, so that |
| 86 | /// we can remove them after we are done working. |
| 87 | std::set<Instruction*> DeadInsts; |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 88 | public: |
Jeff Cohen | a2c59b7 | 2005-03-04 04:04:26 +0000 | [diff] [blame] | 89 | LoopStrengthReduce(unsigned MTAMS = 1) |
| 90 | : MaxTargetAMSize(MTAMS) { |
| 91 | } |
| 92 | |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 93 | virtual bool runOnFunction(Function &) { |
| 94 | LI = &getAnalysis<LoopInfo>(); |
| 95 | DS = &getAnalysis<DominatorSet>(); |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 96 | SE = &getAnalysis<ScalarEvolution>(); |
| 97 | TD = &getAnalysis<TargetData>(); |
| 98 | UIntPtrTy = TD->getIntPtrType(); |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 99 | Changed = false; |
| 100 | |
| 101 | for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I) |
| 102 | runOnLoop(*I); |
| 103 | return Changed; |
| 104 | } |
| 105 | |
| 106 | virtual void getAnalysisUsage(AnalysisUsage &AU) const { |
| 107 | AU.setPreservesCFG(); |
Jeff Cohen | 39751c3 | 2005-02-27 19:37:07 +0000 | [diff] [blame] | 108 | AU.addRequiredID(LoopSimplifyID); |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 109 | AU.addRequired<LoopInfo>(); |
| 110 | AU.addRequired<DominatorSet>(); |
Jeff Cohen | a2c59b7 | 2005-03-04 04:04:26 +0000 | [diff] [blame] | 111 | AU.addRequired<TargetData>(); |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 112 | AU.addRequired<ScalarEvolution>(); |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 113 | } |
| 114 | private: |
| 115 | void runOnLoop(Loop *L); |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 116 | bool AddUsersIfInteresting(Instruction *I, Loop *L); |
| 117 | void AnalyzeGetElementPtrUsers(GetElementPtrInst *GEP, Instruction *I, |
| 118 | Loop *L); |
| 119 | |
| 120 | void StrengthReduceStridedIVUsers(Value *Stride, IVUse &Uses, Loop *L, |
| 121 | bool isOnlyStride); |
| 122 | |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 123 | void strengthReduceGEP(GetElementPtrInst *GEPI, Loop *L, |
Jeff Cohen | be37fa0 | 2005-03-05 22:40:34 +0000 | [diff] [blame] | 124 | GEPCache* GEPCache, |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 125 | Instruction *InsertBefore, |
| 126 | std::set<Instruction*> &DeadInsts); |
| 127 | void DeleteTriviallyDeadInstructions(std::set<Instruction*> &Insts); |
| 128 | }; |
Misha Brukman | b1c9317 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 129 | RegisterOpt<LoopStrengthReduce> X("loop-reduce", |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 130 | "Strength Reduce GEP Uses of Ind. Vars"); |
| 131 | } |
| 132 | |
Jeff Cohen | a2c59b7 | 2005-03-04 04:04:26 +0000 | [diff] [blame] | 133 | FunctionPass *llvm::createLoopStrengthReducePass(unsigned MaxTargetAMSize) { |
| 134 | return new LoopStrengthReduce(MaxTargetAMSize); |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | /// DeleteTriviallyDeadInstructions - If any of the instructions is the |
| 138 | /// specified set are trivially dead, delete them and see if this makes any of |
| 139 | /// their operands subsequently dead. |
| 140 | void LoopStrengthReduce:: |
| 141 | DeleteTriviallyDeadInstructions(std::set<Instruction*> &Insts) { |
| 142 | while (!Insts.empty()) { |
| 143 | Instruction *I = *Insts.begin(); |
| 144 | Insts.erase(Insts.begin()); |
| 145 | if (isInstructionTriviallyDead(I)) { |
Jeff Cohen | 8ea6f9e | 2005-03-01 03:46:11 +0000 | [diff] [blame] | 146 | for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) |
| 147 | if (Instruction *U = dyn_cast<Instruction>(I->getOperand(i))) |
| 148 | Insts.insert(U); |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 149 | I->getParent()->getInstList().erase(I); |
| 150 | Changed = true; |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | |
Jeff Cohen | 39751c3 | 2005-02-27 19:37:07 +0000 | [diff] [blame] | 155 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 156 | /// CanReduceSCEV - Return true if we can strength reduce this scalar evolution |
| 157 | /// in the specified loop. |
| 158 | static bool CanReduceSCEV(const SCEVHandle &SH, Loop *L) { |
| 159 | SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(SH); |
| 160 | if (!AddRec || AddRec->getLoop() != L) return false; |
Jeff Cohen | a2c59b7 | 2005-03-04 04:04:26 +0000 | [diff] [blame] | 161 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 162 | // FIXME: Generalize to non-affine IV's. |
| 163 | if (!AddRec->isAffine()) return false; |
Misha Brukman | b1c9317 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 164 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 165 | // FIXME: generalize to IV's with more complex strides (must emit stride |
| 166 | // expression outside of loop!) |
| 167 | if (isa<SCEVConstant>(AddRec->getOperand(1))) |
| 168 | return true; |
Jeff Cohen | a2c59b7 | 2005-03-04 04:04:26 +0000 | [diff] [blame] | 169 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 170 | // We handle steps by unsigned values, because we know we won't have to insert |
| 171 | // a cast for them. |
| 172 | if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(AddRec->getOperand(1))) |
| 173 | if (SU->getValue()->getType()->isUnsigned()) |
| 174 | return true; |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 175 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 176 | // Otherwise, no, we can't handle it yet. |
| 177 | return false; |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 178 | } |
| 179 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 180 | |
| 181 | /// GetAdjustedIndex - Adjust the specified GEP sequential type index to match |
| 182 | /// the size of the pointer type, and scale it by the type size. |
| 183 | static SCEVHandle GetAdjustedIndex(const SCEVHandle &Idx, uint64_t TySize, |
| 184 | const Type *UIntPtrTy) { |
| 185 | SCEVHandle Result = Idx; |
| 186 | if (Result->getType()->getUnsignedVersion() != UIntPtrTy) { |
| 187 | if (UIntPtrTy->getPrimitiveSize() < Result->getType()->getPrimitiveSize()) |
| 188 | Result = SCEVTruncateExpr::get(Result, UIntPtrTy); |
| 189 | else |
| 190 | Result = SCEVZeroExtendExpr::get(Result, UIntPtrTy); |
| 191 | } |
| 192 | |
| 193 | // This index is scaled by the type size being indexed. |
| 194 | if (TySize != 1) |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 195 | Result = SCEVMulExpr::get(Result, |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 196 | SCEVConstant::get(ConstantUInt::get(UIntPtrTy, |
| 197 | TySize))); |
| 198 | return Result; |
| 199 | } |
| 200 | |
| 201 | /// AnalyzeGetElementPtrUsers - Analyze all of the users of the specified |
| 202 | /// getelementptr instruction, adding them to the IVUsesByStride table. Note |
| 203 | /// that we only want to analyze a getelementptr instruction once, and it can |
| 204 | /// have multiple operands that are uses of the indvar (e.g. A[i][i]). Because |
| 205 | /// of this, we only process a GEP instruction if its first recurrent operand is |
| 206 | /// "op", otherwise we will either have already processed it or we will sometime |
| 207 | /// later. |
| 208 | void LoopStrengthReduce::AnalyzeGetElementPtrUsers(GetElementPtrInst *GEP, |
| 209 | Instruction *Op, Loop *L) { |
| 210 | // Analyze all of the subscripts of this getelementptr instruction, looking |
| 211 | // for uses that are determined by the trip count of L. First, skip all |
| 212 | // operands the are not dependent on the IV. |
| 213 | |
| 214 | // Build up the base expression. Insert an LLVM cast of the pointer to |
| 215 | // uintptr_t first. |
| 216 | Value *BasePtr; |
| 217 | if (Constant *CB = dyn_cast<Constant>(GEP->getOperand(0))) |
| 218 | BasePtr = ConstantExpr::getCast(CB, UIntPtrTy); |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 219 | else { |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 220 | Value *&BP = CastedBasePointers[GEP->getOperand(0)]; |
| 221 | if (BP == 0) { |
| 222 | BasicBlock::iterator InsertPt; |
| 223 | if (isa<Argument>(GEP->getOperand(0))) { |
| 224 | InsertPt = GEP->getParent()->getParent()->begin()->begin(); |
| 225 | } else { |
| 226 | InsertPt = cast<Instruction>(GEP->getOperand(0)); |
| 227 | if (InvokeInst *II = dyn_cast<InvokeInst>(GEP->getOperand(0))) |
| 228 | InsertPt = II->getNormalDest()->begin(); |
| 229 | else |
| 230 | ++InsertPt; |
| 231 | } |
| 232 | BP = new CastInst(GEP->getOperand(0), UIntPtrTy, |
| 233 | GEP->getOperand(0)->getName(), InsertPt); |
| 234 | } |
| 235 | BasePtr = BP; |
| 236 | } |
| 237 | |
| 238 | SCEVHandle Base = SCEVUnknown::get(BasePtr); |
| 239 | |
| 240 | gep_type_iterator GTI = gep_type_begin(GEP); |
| 241 | unsigned i = 1; |
| 242 | for (; GEP->getOperand(i) != Op; ++i, ++GTI) { |
| 243 | // If this is a use of a recurrence that we can analyze, and it comes before |
| 244 | // Op does in the GEP operand list, we will handle this when we process this |
| 245 | // operand. |
| 246 | if (const StructType *STy = dyn_cast<StructType>(*GTI)) { |
| 247 | const StructLayout *SL = TD->getStructLayout(STy); |
| 248 | unsigned Idx = cast<ConstantUInt>(GEP->getOperand(i))->getValue(); |
| 249 | uint64_t Offset = SL->MemberOffsets[Idx]; |
| 250 | Base = SCEVAddExpr::get(Base, SCEVUnknown::getIntegerSCEV(Offset, |
| 251 | UIntPtrTy)); |
| 252 | } else { |
| 253 | SCEVHandle Idx = SE->getSCEV(GEP->getOperand(i)); |
Chris Lattner | 9ef1294 | 2005-08-02 01:32:29 +0000 | [diff] [blame^] | 254 | |
| 255 | // If this operand is reducible, and it's not the one we are looking at |
| 256 | // currently, do not process the GEP at this time. |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 257 | if (CanReduceSCEV(Idx, L)) |
| 258 | return; |
| 259 | Base = SCEVAddExpr::get(Base, GetAdjustedIndex(Idx, |
| 260 | TD->getTypeSize(GTI.getIndexedType()), UIntPtrTy)); |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | // Get the index, convert it to intptr_t. |
| 265 | SCEVHandle GEPIndexExpr = |
| 266 | GetAdjustedIndex(SE->getSCEV(Op), TD->getTypeSize(GTI.getIndexedType()), |
| 267 | UIntPtrTy); |
| 268 | |
| 269 | // Process all remaining subscripts in the GEP instruction. |
| 270 | for (++i, ++GTI; i != GEP->getNumOperands(); ++i, ++GTI) |
| 271 | if (const StructType *STy = dyn_cast<StructType>(*GTI)) { |
| 272 | const StructLayout *SL = TD->getStructLayout(STy); |
| 273 | unsigned Idx = cast<ConstantUInt>(GEP->getOperand(i))->getValue(); |
| 274 | uint64_t Offset = SL->MemberOffsets[Idx]; |
| 275 | Base = SCEVAddExpr::get(Base, SCEVUnknown::getIntegerSCEV(Offset, |
| 276 | UIntPtrTy)); |
| 277 | } else { |
| 278 | SCEVHandle Idx = SE->getSCEV(GEP->getOperand(i)); |
| 279 | if (CanReduceSCEV(Idx, L)) { // Another IV subscript |
| 280 | GEPIndexExpr = SCEVAddExpr::get(GEPIndexExpr, |
| 281 | GetAdjustedIndex(Idx, TD->getTypeSize(GTI.getIndexedType()), |
| 282 | UIntPtrTy)); |
| 283 | assert(CanReduceSCEV(GEPIndexExpr, L) && |
| 284 | "Cannot reduce the sum of two reducible SCEV's??"); |
| 285 | } else { |
| 286 | Base = SCEVAddExpr::get(Base, GetAdjustedIndex(Idx, |
| 287 | TD->getTypeSize(GTI.getIndexedType()), UIntPtrTy)); |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | assert(CanReduceSCEV(GEPIndexExpr, L) && "Non reducible idx??"); |
| 292 | |
Chris Lattner | 9ef1294 | 2005-08-02 01:32:29 +0000 | [diff] [blame^] | 293 | // FIXME: If the base is not loop invariant, we currently cannot emit this. |
| 294 | if (!Base->isLoopInvariant(L)) { |
| 295 | DEBUG(std::cerr << "IGNORING GEP due to non-invaiant base: " |
| 296 | << *Base << "\n"); |
| 297 | return; |
| 298 | } |
| 299 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 300 | Base = SCEVAddExpr::get(Base, cast<SCEVAddRecExpr>(GEPIndexExpr)->getStart()); |
| 301 | SCEVHandle Stride = cast<SCEVAddRecExpr>(GEPIndexExpr)->getOperand(1); |
| 302 | |
| 303 | DEBUG(std::cerr << "GEP BASE : " << *Base << "\n"); |
| 304 | DEBUG(std::cerr << "GEP STRIDE: " << *Stride << "\n"); |
| 305 | |
| 306 | Value *Step = 0; // Step of ISE. |
| 307 | if (SCEVConstant *SC = dyn_cast<SCEVConstant>(Stride)) |
| 308 | /// Always get the step value as an unsigned value. |
| 309 | Step = ConstantExpr::getCast(SC->getValue(), |
| 310 | SC->getValue()->getType()->getUnsignedVersion()); |
| 311 | else |
| 312 | Step = cast<SCEVUnknown>(Stride)->getValue(); |
| 313 | assert(Step->getType()->isUnsigned() && "Bad step value!"); |
| 314 | |
| 315 | |
| 316 | // Now that we know the base and stride contributed by the GEP instruction, |
| 317 | // process all users. |
| 318 | for (Value::use_iterator UI = GEP->use_begin(), E = GEP->use_end(); |
| 319 | UI != E; ++UI) { |
| 320 | Instruction *User = cast<Instruction>(*UI); |
| 321 | |
| 322 | // Do not infinitely recurse on PHI nodes. |
| 323 | if (isa<PHINode>(User) && User->getParent() == L->getHeader()) |
| 324 | continue; |
| 325 | |
| 326 | // If this is an instruction defined in a nested loop, or outside this loop, |
| 327 | // don't mess with it. |
| 328 | if (LI->getLoopFor(User->getParent()) != L) |
| 329 | continue; |
| 330 | |
| 331 | DEBUG(std::cerr << "FOUND USER: " << *User |
| 332 | << " OF STRIDE: " << *Step << " BASE = " << *Base << "\n"); |
| 333 | |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 334 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 335 | // Okay, we found a user that we cannot reduce. Analyze the instruction |
| 336 | // and decide what to do with it. |
| 337 | IVUsesByStride[Step].addUser(Base, User, GEP); |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | /// AddUsersIfInteresting - Inspect the specified instruction. If it is a |
| 342 | /// reducible SCEV, recursively add its users to the IVUsesByStride set and |
| 343 | /// return true. Otherwise, return false. |
| 344 | bool LoopStrengthReduce::AddUsersIfInteresting(Instruction *I, Loop *L) { |
Nate Begeman | 17a0e2af | 2005-07-30 00:21:31 +0000 | [diff] [blame] | 345 | if (I->getType() == Type::VoidTy) return false; |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 346 | SCEVHandle ISE = SE->getSCEV(I); |
| 347 | if (!CanReduceSCEV(ISE, L)) return false; |
| 348 | |
| 349 | SCEVAddRecExpr *AR = cast<SCEVAddRecExpr>(ISE); |
| 350 | SCEVHandle Start = AR->getStart(); |
| 351 | |
| 352 | // Get the step value, canonicalizing to an unsigned integer type so that |
| 353 | // lookups in the map will match. |
| 354 | Value *Step = 0; // Step of ISE. |
| 355 | if (SCEVConstant *SC = dyn_cast<SCEVConstant>(AR->getOperand(1))) |
| 356 | /// Always get the step value as an unsigned value. |
| 357 | Step = ConstantExpr::getCast(SC->getValue(), |
| 358 | SC->getValue()->getType()->getUnsignedVersion()); |
| 359 | else |
| 360 | Step = cast<SCEVUnknown>(AR->getOperand(1))->getValue(); |
| 361 | assert(Step->getType()->isUnsigned() && "Bad step value!"); |
| 362 | |
| 363 | std::set<GetElementPtrInst*> AnalyzedGEPs; |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 364 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 365 | for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;++UI){ |
| 366 | Instruction *User = cast<Instruction>(*UI); |
| 367 | |
| 368 | // Do not infinitely recurse on PHI nodes. |
| 369 | if (isa<PHINode>(User) && User->getParent() == L->getHeader()) |
| 370 | continue; |
| 371 | |
| 372 | // If this is an instruction defined in a nested loop, or outside this loop, |
| 373 | // don't mess with it. |
| 374 | if (LI->getLoopFor(User->getParent()) != L) |
| 375 | continue; |
| 376 | |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 377 | // Next, see if this user is analyzable itself! |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 378 | if (!AddUsersIfInteresting(User, L)) { |
| 379 | if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(User)) { |
| 380 | // If this is a getelementptr instruction, figure out what linear |
| 381 | // expression of induction variable is actually being used. |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 382 | // |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 383 | if (AnalyzedGEPs.insert(GEP).second) // Not already analyzed? |
| 384 | AnalyzeGetElementPtrUsers(GEP, I, L); |
| 385 | } else { |
| 386 | DEBUG(std::cerr << "FOUND USER: " << *User |
| 387 | << " OF SCEV: " << *ISE << "\n"); |
| 388 | |
| 389 | // Okay, we found a user that we cannot reduce. Analyze the instruction |
| 390 | // and decide what to do with it. |
| 391 | IVUsesByStride[Step].addUser(Start, User, I); |
| 392 | } |
| 393 | } |
| 394 | } |
| 395 | return true; |
| 396 | } |
| 397 | |
| 398 | namespace { |
| 399 | /// BasedUser - For a particular base value, keep information about how we've |
| 400 | /// partitioned the expression so far. |
| 401 | struct BasedUser { |
| 402 | /// Inst - The instruction using the induction variable. |
| 403 | Instruction *Inst; |
| 404 | |
| 405 | /// Op - The value to replace with the EmittedBase. |
| 406 | Value *Op; |
| 407 | |
| 408 | /// Imm - The immediate value that should be added to the base immediately |
| 409 | /// before Inst, because it will be folded into the imm field of the |
| 410 | /// instruction. |
| 411 | SCEVHandle Imm; |
| 412 | |
| 413 | /// EmittedBase - The actual value* to use for the base value of this |
| 414 | /// operation. This is null if we should just use zero so far. |
| 415 | Value *EmittedBase; |
| 416 | |
| 417 | BasedUser(Instruction *I, Value *V, const SCEVHandle &IMM) |
| 418 | : Inst(I), Op(V), Imm(IMM), EmittedBase(0) {} |
| 419 | |
| 420 | |
| 421 | // No need to compare these. |
| 422 | bool operator<(const BasedUser &BU) const { return 0; } |
| 423 | |
| 424 | void dump() const; |
| 425 | }; |
| 426 | } |
| 427 | |
| 428 | void BasedUser::dump() const { |
| 429 | std::cerr << " Imm=" << *Imm; |
| 430 | if (EmittedBase) |
| 431 | std::cerr << " EB=" << *EmittedBase; |
| 432 | |
| 433 | std::cerr << " Inst: " << *Inst; |
| 434 | } |
| 435 | |
| 436 | /// isTargetConstant - Return true if the following can be referenced by the |
| 437 | /// immediate field of a target instruction. |
| 438 | static bool isTargetConstant(const SCEVHandle &V) { |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 439 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 440 | // FIXME: Look at the target to decide if &GV is a legal constant immediate. |
| 441 | if (isa<SCEVConstant>(V)) return true; |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 442 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 443 | return false; // ENABLE this for x86 |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 444 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 445 | if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(V)) |
| 446 | if (ConstantExpr *CE = dyn_cast<ConstantExpr>(SU->getValue())) |
| 447 | if (CE->getOpcode() == Instruction::Cast) |
| 448 | if (isa<GlobalValue>(CE->getOperand(0))) |
| 449 | // FIXME: should check to see that the dest is uintptr_t! |
| 450 | return true; |
| 451 | return false; |
| 452 | } |
| 453 | |
| 454 | /// GetImmediateValues - Look at Val, and pull out any additions of constants |
| 455 | /// that can fit into the immediate field of instructions in the target. |
| 456 | static SCEVHandle GetImmediateValues(SCEVHandle Val, bool isAddress) { |
| 457 | if (!isAddress) |
| 458 | return SCEVUnknown::getIntegerSCEV(0, Val->getType()); |
| 459 | if (isTargetConstant(Val)) |
| 460 | return Val; |
| 461 | |
| 462 | SCEVAddExpr *SAE = dyn_cast<SCEVAddExpr>(Val); |
| 463 | if (SAE) { |
| 464 | unsigned i = 0; |
| 465 | for (; i != SAE->getNumOperands(); ++i) |
| 466 | if (isTargetConstant(SAE->getOperand(i))) { |
| 467 | SCEVHandle ImmVal = SAE->getOperand(i); |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 468 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 469 | // If there are any other immediates that we can handle here, pull them |
| 470 | // out too. |
| 471 | for (++i; i != SAE->getNumOperands(); ++i) |
| 472 | if (isTargetConstant(SAE->getOperand(i))) |
| 473 | ImmVal = SCEVAddExpr::get(ImmVal, SAE->getOperand(i)); |
| 474 | return ImmVal; |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | return SCEVUnknown::getIntegerSCEV(0, Val->getType()); |
| 479 | } |
| 480 | |
| 481 | /// StrengthReduceStridedIVUsers - Strength reduce all of the users of a single |
| 482 | /// stride of IV. All of the users may have different starting values, and this |
| 483 | /// may not be the only stride (we know it is if isOnlyStride is true). |
| 484 | void LoopStrengthReduce::StrengthReduceStridedIVUsers(Value *Stride, |
| 485 | IVUse &Uses, Loop *L, |
| 486 | bool isOnlyStride) { |
| 487 | // Transform our list of users and offsets to a bit more complex table. In |
| 488 | // this new vector, the first entry for each element is the base of the |
| 489 | // strided access, and the second is the BasedUser object for the use. We |
| 490 | // progressively move information from the first to the second entry, until we |
| 491 | // eventually emit the object. |
| 492 | std::vector<std::pair<SCEVHandle, BasedUser> > UsersToProcess; |
| 493 | UsersToProcess.reserve(Uses.Users.size()); |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 494 | |
| 495 | SCEVHandle ZeroBase = SCEVUnknown::getIntegerSCEV(0, |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 496 | Uses.Users[0].first->getType()); |
| 497 | |
| 498 | for (unsigned i = 0, e = Uses.Users.size(); i != e; ++i) |
| 499 | UsersToProcess.push_back(std::make_pair(Uses.Users[i].first, |
| 500 | BasedUser(Uses.Users[i].second, |
| 501 | Uses.UserOperands[i], |
| 502 | ZeroBase))); |
| 503 | |
| 504 | // First pass, figure out what we can represent in the immediate fields of |
| 505 | // instructions. If we can represent anything there, move it to the imm |
| 506 | // fields of the BasedUsers. |
| 507 | for (unsigned i = 0, e = UsersToProcess.size(); i != e; ++i) { |
| 508 | bool isAddress = isa<LoadInst>(UsersToProcess[i].second.Inst) || |
| 509 | isa<StoreInst>(UsersToProcess[i].second.Inst); |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 510 | UsersToProcess[i].second.Imm = GetImmediateValues(UsersToProcess[i].first, |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 511 | isAddress); |
| 512 | UsersToProcess[i].first = SCEV::getMinusSCEV(UsersToProcess[i].first, |
| 513 | UsersToProcess[i].second.Imm); |
| 514 | |
| 515 | DEBUG(std::cerr << "BASE: " << *UsersToProcess[i].first); |
| 516 | DEBUG(UsersToProcess[i].second.dump()); |
| 517 | } |
| 518 | |
| 519 | SCEVExpander Rewriter(*SE, *LI); |
| 520 | BasicBlock *Preheader = L->getLoopPreheader(); |
| 521 | Instruction *PreInsertPt = Preheader->getTerminator(); |
| 522 | Instruction *PhiInsertBefore = L->getHeader()->begin(); |
| 523 | |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 524 | assert(isa<PHINode>(PhiInsertBefore) && |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 525 | "How could this loop have IV's without any phis?"); |
| 526 | PHINode *SomeLoopPHI = cast<PHINode>(PhiInsertBefore); |
| 527 | assert(SomeLoopPHI->getNumIncomingValues() == 2 && |
| 528 | "This loop isn't canonicalized right"); |
| 529 | BasicBlock *LatchBlock = |
| 530 | SomeLoopPHI->getIncomingBlock(SomeLoopPHI->getIncomingBlock(0) == Preheader); |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 531 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 532 | // FIXME: This loop needs increasing levels of intelligence. |
| 533 | // STAGE 0: just emit everything as its own base. <-- We are here |
| 534 | // STAGE 1: factor out common vars from bases, and try and push resulting |
| 535 | // constants into Imm field. |
| 536 | // STAGE 2: factor out large constants to try and make more constants |
| 537 | // acceptable for target loads and stores. |
| 538 | std::sort(UsersToProcess.begin(), UsersToProcess.end()); |
| 539 | |
| 540 | while (!UsersToProcess.empty()) { |
| 541 | // Create a new Phi for this base, and stick it in the loop header. |
| 542 | Value *Replaced = UsersToProcess.front().second.Op; |
| 543 | const Type *ReplacedTy = Replaced->getType(); |
| 544 | PHINode *NewPHI = new PHINode(ReplacedTy, Replaced->getName()+".str", |
| 545 | PhiInsertBefore); |
| 546 | |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 547 | // Emit the initial base value into the loop preheader, and add it to the |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 548 | // Phi node. |
| 549 | Value *BaseV = Rewriter.expandCodeFor(UsersToProcess.front().first, |
| 550 | PreInsertPt, ReplacedTy); |
| 551 | NewPHI->addIncoming(BaseV, Preheader); |
| 552 | |
| 553 | // Emit the increment of the base value before the terminator of the loop |
| 554 | // latch block, and add it to the Phi node. |
| 555 | SCEVHandle Inc = SCEVAddExpr::get(SCEVUnknown::get(NewPHI), |
| 556 | SCEVUnknown::get(Stride)); |
| 557 | |
| 558 | Value *IncV = Rewriter.expandCodeFor(Inc, LatchBlock->getTerminator(), |
| 559 | ReplacedTy); |
| 560 | IncV->setName(NewPHI->getName()+".inc"); |
| 561 | NewPHI->addIncoming(IncV, LatchBlock); |
| 562 | |
| 563 | // Emit the code to add the immediate offset to the Phi value, just before |
| 564 | // the instruction that we identified as using this stride and base. |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 565 | // First, empty the SCEVExpander's expression map so that we are guaranteed |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 566 | // to have the code emitted where we expect it. |
| 567 | Rewriter.clear(); |
| 568 | SCEVHandle NewValSCEV = SCEVAddExpr::get(SCEVUnknown::get(NewPHI), |
| 569 | UsersToProcess.front().second.Imm); |
| 570 | Value *newVal = Rewriter.expandCodeFor(NewValSCEV, |
| 571 | UsersToProcess.front().second.Inst, |
| 572 | ReplacedTy); |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 573 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 574 | // Replace the use of the operand Value with the new Phi we just created. |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 575 | DEBUG(std::cerr << "REPLACING: " << *Replaced << "IN: " << |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 576 | *UsersToProcess.front().second.Inst << "WITH: "<< *newVal << '\n'); |
| 577 | UsersToProcess.front().second.Inst->replaceUsesOfWith(Replaced, newVal); |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 578 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 579 | // Mark old value we replaced as possibly dead, so that it is elminated |
| 580 | // if we just replaced the last use of that value. |
| 581 | DeadInsts.insert(cast<Instruction>(Replaced)); |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 582 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 583 | UsersToProcess.erase(UsersToProcess.begin()); |
| 584 | ++NumReduced; |
| 585 | |
| 586 | // TODO: Next, find out which base index is the most common, pull it out. |
| 587 | } |
| 588 | |
| 589 | // IMPORTANT TODO: Figure out how to partition the IV's with this stride, but |
| 590 | // different starting values, into different PHIs. |
Jeff Cohen | 546fd59 | 2005-07-30 18:33:25 +0000 | [diff] [blame] | 591 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 592 | // BEFORE writing this, it's probably useful to handle GEP's. |
| 593 | |
| 594 | // NOTE: pull all constants together, for REG+IMM addressing, include &GV in |
| 595 | // 'IMM' if the target supports it. |
| 596 | } |
| 597 | |
| 598 | |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 599 | void LoopStrengthReduce::runOnLoop(Loop *L) { |
| 600 | // First step, transform all loops nesting inside of this loop. |
| 601 | for (LoopInfo::iterator I = L->begin(), E = L->end(); I != E; ++I) |
| 602 | runOnLoop(*I); |
| 603 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 604 | // Next, find all uses of induction variables in this loop, and catagorize |
| 605 | // them by stride. Start by finding all of the PHI nodes in the header for |
| 606 | // this loop. If they are induction variables, inspect their uses. |
| 607 | for (BasicBlock::iterator I = L->getHeader()->begin(); isa<PHINode>(I); ++I) |
| 608 | AddUsersIfInteresting(I, L); |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 609 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 610 | // If we have nothing to do, return. |
| 611 | //if (IVUsesByStride.empty()) return; |
Misha Brukman | b1c9317 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 612 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 613 | // FIXME: We can widen subreg IV's here for RISC targets. e.g. instead of |
| 614 | // doing computation in byte values, promote to 32-bit values if safe. |
| 615 | |
| 616 | // FIXME: Attempt to reuse values across multiple IV's. In particular, we |
| 617 | // could have something like "for(i) { foo(i*8); bar(i*16) }", which should be |
| 618 | // codegened as "for (j = 0;; j+=8) { foo(j); bar(j+j); }" on X86/PPC. Need |
| 619 | // to be careful that IV's are all the same type. Only works for intptr_t |
| 620 | // indvars. |
| 621 | |
| 622 | // If we only have one stride, we can more aggressively eliminate some things. |
| 623 | bool HasOneStride = IVUsesByStride.size() == 1; |
| 624 | |
| 625 | for (std::map<Value*, IVUse>::iterator SI = IVUsesByStride.begin(), |
| 626 | E = IVUsesByStride.end(); SI != E; ++SI) |
| 627 | StrengthReduceStridedIVUsers(SI->first, SI->second, L, HasOneStride); |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 628 | |
| 629 | // Clean up after ourselves |
| 630 | if (!DeadInsts.empty()) { |
| 631 | DeleteTriviallyDeadInstructions(DeadInsts); |
| 632 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 633 | BasicBlock::iterator I = L->getHeader()->begin(); |
| 634 | PHINode *PN; |
Chris Lattner | 564900e | 2005-08-02 00:41:11 +0000 | [diff] [blame] | 635 | for (; (PN = dyn_cast<PHINode>(I)); ) { |
| 636 | ++I; // Preincrement iterator to avoid invalidating it when deleting PN. |
| 637 | |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 638 | // At this point, we know that we have killed one or more GEP instructions. |
| 639 | // It is worth checking to see if the cann indvar is also dead, so that we |
| 640 | // can remove it as well. The requirements for the cann indvar to be |
| 641 | // considered dead are: |
| 642 | // 1. the cann indvar has one use |
| 643 | // 2. the use is an add instruction |
| 644 | // 3. the add has one use |
| 645 | // 4. the add is used by the cann indvar |
| 646 | // If all four cases above are true, then we can remove both the add and |
| 647 | // the cann indvar. |
| 648 | // FIXME: this needs to eliminate an induction variable even if it's being |
| 649 | // compared against some value to decide loop termination. |
| 650 | if (PN->hasOneUse()) { |
| 651 | BinaryOperator *BO = dyn_cast<BinaryOperator>(*(PN->use_begin())); |
| 652 | if (BO && BO->getOpcode() == Instruction::Add) |
| 653 | if (BO->hasOneUse()) { |
| 654 | if (PN == dyn_cast<PHINode>(*(BO->use_begin()))) { |
| 655 | DeadInsts.insert(BO); |
| 656 | // Break the cycle, then delete the PHI. |
| 657 | PN->replaceAllUsesWith(UndefValue::get(PN->getType())); |
| 658 | PN->eraseFromParent(); |
| 659 | } |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 660 | } |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 661 | } |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 662 | } |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 663 | DeleteTriviallyDeadInstructions(DeadInsts); |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 664 | } |
Nate Begeman | e68bcd1 | 2005-07-30 00:15:07 +0000 | [diff] [blame] | 665 | |
| 666 | IVUsesByStride.clear(); |
| 667 | return; |
Nate Begeman | b18121e | 2004-10-18 21:08:22 +0000 | [diff] [blame] | 668 | } |