LLVM  mainline
SimplifyIndVar.cpp
Go to the documentation of this file.
00001 //===-- SimplifyIndVar.cpp - Induction variable simplification ------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements induction variable simplification. It does
00011 // not define any actual pass or policy, but provides a single function to
00012 // simplify a loop's induction variables based on ScalarEvolution.
00013 //
00014 //===----------------------------------------------------------------------===//
00015 
00016 #include "llvm/Transforms/Utils/SimplifyIndVar.h"
00017 #include "llvm/ADT/STLExtras.h"
00018 #include "llvm/ADT/SmallVector.h"
00019 #include "llvm/ADT/Statistic.h"
00020 #include "llvm/Analysis/IVUsers.h"
00021 #include "llvm/Analysis/LoopInfo.h"
00022 #include "llvm/Analysis/LoopPass.h"
00023 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
00024 #include "llvm/IR/DataLayout.h"
00025 #include "llvm/IR/Dominators.h"
00026 #include "llvm/IR/IRBuilder.h"
00027 #include "llvm/IR/Instructions.h"
00028 #include "llvm/IR/IntrinsicInst.h"
00029 #include "llvm/Support/CommandLine.h"
00030 #include "llvm/Support/Debug.h"
00031 #include "llvm/Support/raw_ostream.h"
00032 
00033 using namespace llvm;
00034 
00035 #define DEBUG_TYPE "indvars"
00036 
00037 STATISTIC(NumElimIdentity, "Number of IV identities eliminated");
00038 STATISTIC(NumElimOperand,  "Number of IV operands folded into a use");
00039 STATISTIC(NumElimRem     , "Number of IV remainder operations eliminated");
00040 STATISTIC(NumElimCmp     , "Number of IV comparisons eliminated");
00041 
00042 namespace {
00043   /// This is a utility for simplifying induction variables
00044   /// based on ScalarEvolution. It is the primary instrument of the
00045   /// IndvarSimplify pass, but it may also be directly invoked to cleanup after
00046   /// other loop passes that preserve SCEV.
00047   class SimplifyIndvar {
00048     Loop             *L;
00049     LoopInfo         *LI;
00050     ScalarEvolution  *SE;
00051 
00052     SmallVectorImpl<WeakVH> &DeadInsts;
00053 
00054     bool Changed;
00055 
00056   public:
00057     SimplifyIndvar(Loop *Loop, ScalarEvolution *SE, LoopInfo *LI,
00058                    SmallVectorImpl<WeakVH> &Dead, IVUsers *IVU = nullptr)
00059         : L(Loop), LI(LI), SE(SE), DeadInsts(Dead), Changed(false) {
00060       assert(LI && "IV simplification requires LoopInfo");
00061     }
00062 
00063     bool hasChanged() const { return Changed; }
00064 
00065     /// Iteratively perform simplification on a worklist of users of the
00066     /// specified induction variable. This is the top-level driver that applies
00067     /// all simplicitions to users of an IV.
00068     void simplifyUsers(PHINode *CurrIV, IVVisitor *V = nullptr);
00069 
00070     Value *foldIVUser(Instruction *UseInst, Instruction *IVOperand);
00071 
00072     bool eliminateIVUser(Instruction *UseInst, Instruction *IVOperand);
00073     void eliminateIVComparison(ICmpInst *ICmp, Value *IVOperand);
00074     void eliminateIVRemainder(BinaryOperator *Rem, Value *IVOperand,
00075                               bool IsSigned);
00076     bool strengthenOverflowingOperation(BinaryOperator *OBO, Value *IVOperand);
00077 
00078     Instruction *splitOverflowIntrinsic(Instruction *IVUser,
00079                                         const DominatorTree *DT);
00080   };
00081 }
00082 
00083 /// Fold an IV operand into its use.  This removes increments of an
00084 /// aligned IV when used by a instruction that ignores the low bits.
00085 ///
00086 /// IVOperand is guaranteed SCEVable, but UseInst may not be.
00087 ///
00088 /// Return the operand of IVOperand for this induction variable if IVOperand can
00089 /// be folded (in case more folding opportunities have been exposed).
00090 /// Otherwise return null.
00091 Value *SimplifyIndvar::foldIVUser(Instruction *UseInst, Instruction *IVOperand) {
00092   Value *IVSrc = nullptr;
00093   unsigned OperIdx = 0;
00094   const SCEV *FoldedExpr = nullptr;
00095   switch (UseInst->getOpcode()) {
00096   default:
00097     return nullptr;
00098   case Instruction::UDiv:
00099   case Instruction::LShr:
00100     // We're only interested in the case where we know something about
00101     // the numerator and have a constant denominator.
00102     if (IVOperand != UseInst->getOperand(OperIdx) ||
00103         !isa<ConstantInt>(UseInst->getOperand(1)))
00104       return nullptr;
00105 
00106     // Attempt to fold a binary operator with constant operand.
00107     // e.g. ((I + 1) >> 2) => I >> 2
00108     if (!isa<BinaryOperator>(IVOperand)
00109         || !isa<ConstantInt>(IVOperand->getOperand(1)))
00110       return nullptr;
00111 
00112     IVSrc = IVOperand->getOperand(0);
00113     // IVSrc must be the (SCEVable) IV, since the other operand is const.
00114     assert(SE->isSCEVable(IVSrc->getType()) && "Expect SCEVable IV operand");
00115 
00116     ConstantInt *D = cast<ConstantInt>(UseInst->getOperand(1));
00117     if (UseInst->getOpcode() == Instruction::LShr) {
00118       // Get a constant for the divisor. See createSCEV.
00119       uint32_t BitWidth = cast<IntegerType>(UseInst->getType())->getBitWidth();
00120       if (D->getValue().uge(BitWidth))
00121         return nullptr;
00122 
00123       D = ConstantInt::get(UseInst->getContext(),
00124                            APInt::getOneBitSet(BitWidth, D->getZExtValue()));
00125     }
00126     FoldedExpr = SE->getUDivExpr(SE->getSCEV(IVSrc), SE->getSCEV(D));
00127   }
00128   // We have something that might fold it's operand. Compare SCEVs.
00129   if (!SE->isSCEVable(UseInst->getType()))
00130     return nullptr;
00131 
00132   // Bypass the operand if SCEV can prove it has no effect.
00133   if (SE->getSCEV(UseInst) != FoldedExpr)
00134     return nullptr;
00135 
00136   DEBUG(dbgs() << "INDVARS: Eliminated IV operand: " << *IVOperand
00137         << " -> " << *UseInst << '\n');
00138 
00139   UseInst->setOperand(OperIdx, IVSrc);
00140   assert(SE->getSCEV(UseInst) == FoldedExpr && "bad SCEV with folded oper");
00141 
00142   ++NumElimOperand;
00143   Changed = true;
00144   if (IVOperand->use_empty())
00145     DeadInsts.push_back(IVOperand);
00146   return IVSrc;
00147 }
00148 
00149 /// SimplifyIVUsers helper for eliminating useless
00150 /// comparisons against an induction variable.
00151 void SimplifyIndvar::eliminateIVComparison(ICmpInst *ICmp, Value *IVOperand) {
00152   unsigned IVOperIdx = 0;
00153   ICmpInst::Predicate Pred = ICmp->getPredicate();
00154   if (IVOperand != ICmp->getOperand(0)) {
00155     // Swapped
00156     assert(IVOperand == ICmp->getOperand(1) && "Can't find IVOperand");
00157     IVOperIdx = 1;
00158     Pred = ICmpInst::getSwappedPredicate(Pred);
00159   }
00160 
00161   // Get the SCEVs for the ICmp operands.
00162   const SCEV *S = SE->getSCEV(ICmp->getOperand(IVOperIdx));
00163   const SCEV *X = SE->getSCEV(ICmp->getOperand(1 - IVOperIdx));
00164 
00165   // Simplify unnecessary loops away.
00166   const Loop *ICmpLoop = LI->getLoopFor(ICmp->getParent());
00167   S = SE->getSCEVAtScope(S, ICmpLoop);
00168   X = SE->getSCEVAtScope(X, ICmpLoop);
00169 
00170   // If the condition is always true or always false, replace it with
00171   // a constant value.
00172   if (SE->isKnownPredicate(Pred, S, X))
00173     ICmp->replaceAllUsesWith(ConstantInt::getTrue(ICmp->getContext()));
00174   else if (SE->isKnownPredicate(ICmpInst::getInversePredicate(Pred), S, X))
00175     ICmp->replaceAllUsesWith(ConstantInt::getFalse(ICmp->getContext()));
00176   else
00177     return;
00178 
00179   DEBUG(dbgs() << "INDVARS: Eliminated comparison: " << *ICmp << '\n');
00180   ++NumElimCmp;
00181   Changed = true;
00182   DeadInsts.push_back(ICmp);
00183 }
00184 
00185 /// SimplifyIVUsers helper for eliminating useless
00186 /// remainder operations operating on an induction variable.
00187 void SimplifyIndvar::eliminateIVRemainder(BinaryOperator *Rem,
00188                                       Value *IVOperand,
00189                                       bool IsSigned) {
00190   // We're only interested in the case where we know something about
00191   // the numerator.
00192   if (IVOperand != Rem->getOperand(0))
00193     return;
00194 
00195   // Get the SCEVs for the ICmp operands.
00196   const SCEV *S = SE->getSCEV(Rem->getOperand(0));
00197   const SCEV *X = SE->getSCEV(Rem->getOperand(1));
00198 
00199   // Simplify unnecessary loops away.
00200   const Loop *ICmpLoop = LI->getLoopFor(Rem->getParent());
00201   S = SE->getSCEVAtScope(S, ICmpLoop);
00202   X = SE->getSCEVAtScope(X, ICmpLoop);
00203 
00204   // i % n  -->  i  if i is in [0,n).
00205   if ((!IsSigned || SE->isKnownNonNegative(S)) &&
00206       SE->isKnownPredicate(IsSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
00207                            S, X))
00208     Rem->replaceAllUsesWith(Rem->getOperand(0));
00209   else {
00210     // (i+1) % n  -->  (i+1)==n?0:(i+1)  if i is in [0,n).
00211     const SCEV *LessOne =
00212       SE->getMinusSCEV(S, SE->getConstant(S->getType(), 1));
00213     if (IsSigned && !SE->isKnownNonNegative(LessOne))
00214       return;
00215 
00216     if (!SE->isKnownPredicate(IsSigned ?
00217                               ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT,
00218                               LessOne, X))
00219       return;
00220 
00221     ICmpInst *ICmp = new ICmpInst(Rem, ICmpInst::ICMP_EQ,
00222                                   Rem->getOperand(0), Rem->getOperand(1));
00223     SelectInst *Sel =
00224       SelectInst::Create(ICmp,
00225                          ConstantInt::get(Rem->getType(), 0),
00226                          Rem->getOperand(0), "tmp", Rem);
00227     Rem->replaceAllUsesWith(Sel);
00228   }
00229 
00230   DEBUG(dbgs() << "INDVARS: Simplified rem: " << *Rem << '\n');
00231   ++NumElimRem;
00232   Changed = true;
00233   DeadInsts.push_back(Rem);
00234 }
00235 
00236 /// Eliminate an operation that consumes a simple IV and has
00237 /// no observable side-effect given the range of IV values.
00238 /// IVOperand is guaranteed SCEVable, but UseInst may not be.
00239 bool SimplifyIndvar::eliminateIVUser(Instruction *UseInst,
00240                                      Instruction *IVOperand) {
00241   if (ICmpInst *ICmp = dyn_cast<ICmpInst>(UseInst)) {
00242     eliminateIVComparison(ICmp, IVOperand);
00243     return true;
00244   }
00245   if (BinaryOperator *Rem = dyn_cast<BinaryOperator>(UseInst)) {
00246     bool IsSigned = Rem->getOpcode() == Instruction::SRem;
00247     if (IsSigned || Rem->getOpcode() == Instruction::URem) {
00248       eliminateIVRemainder(Rem, IVOperand, IsSigned);
00249       return true;
00250     }
00251   }
00252 
00253   // Eliminate any operation that SCEV can prove is an identity function.
00254   if (!SE->isSCEVable(UseInst->getType()) ||
00255       (UseInst->getType() != IVOperand->getType()) ||
00256       (SE->getSCEV(UseInst) != SE->getSCEV(IVOperand)))
00257     return false;
00258 
00259   DEBUG(dbgs() << "INDVARS: Eliminated identity: " << *UseInst << '\n');
00260 
00261   UseInst->replaceAllUsesWith(IVOperand);
00262   ++NumElimIdentity;
00263   Changed = true;
00264   DeadInsts.push_back(UseInst);
00265   return true;
00266 }
00267 
00268 /// Annotate BO with nsw / nuw if it provably does not signed-overflow /
00269 /// unsigned-overflow.  Returns true if anything changed, false otherwise.
00270 bool SimplifyIndvar::strengthenOverflowingOperation(BinaryOperator *BO,
00271                                                     Value *IVOperand) {
00272 
00273   // Fastpath: we don't have any work to do if `BO` is `nuw` and `nsw`.
00274   if (BO->hasNoUnsignedWrap() && BO->hasNoSignedWrap())
00275     return false;
00276 
00277   const SCEV *(ScalarEvolution::*GetExprForBO)(const SCEV *, const SCEV *,
00278                                                SCEV::NoWrapFlags);
00279 
00280   switch (BO->getOpcode()) {
00281   default:
00282     return false;
00283 
00284   case Instruction::Add:
00285     GetExprForBO = &ScalarEvolution::getAddExpr;
00286     break;
00287 
00288   case Instruction::Sub:
00289     GetExprForBO = &ScalarEvolution::getMinusSCEV;
00290     break;
00291 
00292   case Instruction::Mul:
00293     GetExprForBO = &ScalarEvolution::getMulExpr;
00294     break;
00295   }
00296 
00297   unsigned BitWidth = cast<IntegerType>(BO->getType())->getBitWidth();
00298   Type *WideTy = IntegerType::get(BO->getContext(), BitWidth * 2);
00299   const SCEV *LHS = SE->getSCEV(BO->getOperand(0));
00300   const SCEV *RHS = SE->getSCEV(BO->getOperand(1));
00301 
00302   bool Changed = false;
00303 
00304   if (!BO->hasNoUnsignedWrap()) {
00305     const SCEV *ExtendAfterOp = SE->getZeroExtendExpr(SE->getSCEV(BO), WideTy);
00306     const SCEV *OpAfterExtend = (SE->*GetExprForBO)(
00307       SE->getZeroExtendExpr(LHS, WideTy), SE->getZeroExtendExpr(RHS, WideTy),
00308       SCEV::FlagAnyWrap);
00309     if (ExtendAfterOp == OpAfterExtend) {
00310       BO->setHasNoUnsignedWrap();
00311       SE->forgetValue(BO);
00312       Changed = true;
00313     }
00314   }
00315 
00316   if (!BO->hasNoSignedWrap()) {
00317     const SCEV *ExtendAfterOp = SE->getSignExtendExpr(SE->getSCEV(BO), WideTy);
00318     const SCEV *OpAfterExtend = (SE->*GetExprForBO)(
00319       SE->getSignExtendExpr(LHS, WideTy), SE->getSignExtendExpr(RHS, WideTy),
00320       SCEV::FlagAnyWrap);
00321     if (ExtendAfterOp == OpAfterExtend) {
00322       BO->setHasNoSignedWrap();
00323       SE->forgetValue(BO);
00324       Changed = true;
00325     }
00326   }
00327 
00328   return Changed;
00329 }
00330 
00331 /// \brief Split sadd.with.overflow into add + sadd.with.overflow to allow
00332 /// analysis and optimization.
00333 ///
00334 /// \return A new value representing the non-overflowing add if possible,
00335 /// otherwise return the original value.
00336 Instruction *SimplifyIndvar::splitOverflowIntrinsic(Instruction *IVUser,
00337                                                     const DominatorTree *DT) {
00338   IntrinsicInst *II = dyn_cast<IntrinsicInst>(IVUser);
00339   if (!II || II->getIntrinsicID() != Intrinsic::sadd_with_overflow)
00340     return IVUser;
00341 
00342   // Find a branch guarded by the overflow check.
00343   BranchInst *Branch = nullptr;
00344   Instruction *AddVal = nullptr;
00345   for (User *U : II->users()) {
00346     if (ExtractValueInst *ExtractInst = dyn_cast<ExtractValueInst>(U)) {
00347       if (ExtractInst->getNumIndices() != 1)
00348         continue;
00349       if (ExtractInst->getIndices()[0] == 0)
00350         AddVal = ExtractInst;
00351       else if (ExtractInst->getIndices()[0] == 1 && ExtractInst->hasOneUse())
00352         Branch = dyn_cast<BranchInst>(ExtractInst->user_back());
00353     }
00354   }
00355   if (!AddVal || !Branch)
00356     return IVUser;
00357 
00358   BasicBlock *ContinueBB = Branch->getSuccessor(1);
00359   if (std::next(pred_begin(ContinueBB)) != pred_end(ContinueBB))
00360     return IVUser;
00361 
00362   // Check if all users of the add are provably NSW.
00363   bool AllNSW = true;
00364   for (Use &U : AddVal->uses()) {
00365     if (Instruction *UseInst = dyn_cast<Instruction>(U.getUser())) {
00366       BasicBlock *UseBB = UseInst->getParent();
00367       if (PHINode *PHI = dyn_cast<PHINode>(UseInst))
00368         UseBB = PHI->getIncomingBlock(U);
00369       if (!DT->dominates(ContinueBB, UseBB)) {
00370         AllNSW = false;
00371         break;
00372       }
00373     }
00374   }
00375   if (!AllNSW)
00376     return IVUser;
00377 
00378   // Go for it...
00379   IRBuilder<> Builder(IVUser);
00380   Instruction *AddInst = dyn_cast<Instruction>(
00381     Builder.CreateNSWAdd(II->getOperand(0), II->getOperand(1)));
00382 
00383   // The caller expects the new add to have the same form as the intrinsic. The
00384   // IV operand position must be the same.
00385   assert((AddInst->getOpcode() == Instruction::Add &&
00386           AddInst->getOperand(0) == II->getOperand(0)) &&
00387          "Bad add instruction created from overflow intrinsic.");
00388 
00389   AddVal->replaceAllUsesWith(AddInst);
00390   DeadInsts.push_back(AddVal);
00391   return AddInst;
00392 }
00393 
00394 /// Add all uses of Def to the current IV's worklist.
00395 static void pushIVUsers(
00396   Instruction *Def,
00397   SmallPtrSet<Instruction*,16> &Simplified,
00398   SmallVectorImpl< std::pair<Instruction*,Instruction*> > &SimpleIVUsers) {
00399 
00400   for (User *U : Def->users()) {
00401     Instruction *UI = cast<Instruction>(U);
00402 
00403     // Avoid infinite or exponential worklist processing.
00404     // Also ensure unique worklist users.
00405     // If Def is a LoopPhi, it may not be in the Simplified set, so check for
00406     // self edges first.
00407     if (UI != Def && Simplified.insert(UI).second)
00408       SimpleIVUsers.push_back(std::make_pair(UI, Def));
00409   }
00410 }
00411 
00412 /// Return true if this instruction generates a simple SCEV
00413 /// expression in terms of that IV.
00414 ///
00415 /// This is similar to IVUsers' isInteresting() but processes each instruction
00416 /// non-recursively when the operand is already known to be a simpleIVUser.
00417 ///
00418 static bool isSimpleIVUser(Instruction *I, const Loop *L, ScalarEvolution *SE) {
00419   if (!SE->isSCEVable(I->getType()))
00420     return false;
00421 
00422   // Get the symbolic expression for this instruction.
00423   const SCEV *S = SE->getSCEV(I);
00424 
00425   // Only consider affine recurrences.
00426   const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(S);
00427   if (AR && AR->getLoop() == L)
00428     return true;
00429 
00430   return false;
00431 }
00432 
00433 /// Iteratively perform simplification on a worklist of users
00434 /// of the specified induction variable. Each successive simplification may push
00435 /// more users which may themselves be candidates for simplification.
00436 ///
00437 /// This algorithm does not require IVUsers analysis. Instead, it simplifies
00438 /// instructions in-place during analysis. Rather than rewriting induction
00439 /// variables bottom-up from their users, it transforms a chain of IVUsers
00440 /// top-down, updating the IR only when it encouters a clear optimization
00441 /// opportunitiy.
00442 ///
00443 /// Once DisableIVRewrite is default, LSR will be the only client of IVUsers.
00444 ///
00445 void SimplifyIndvar::simplifyUsers(PHINode *CurrIV, IVVisitor *V) {
00446   if (!SE->isSCEVable(CurrIV->getType()))
00447     return;
00448 
00449   // Instructions processed by SimplifyIndvar for CurrIV.
00450   SmallPtrSet<Instruction*,16> Simplified;
00451 
00452   // Use-def pairs if IV users waiting to be processed for CurrIV.
00453   SmallVector<std::pair<Instruction*, Instruction*>, 8> SimpleIVUsers;
00454 
00455   // Push users of the current LoopPhi. In rare cases, pushIVUsers may be
00456   // called multiple times for the same LoopPhi. This is the proper thing to
00457   // do for loop header phis that use each other.
00458   pushIVUsers(CurrIV, Simplified, SimpleIVUsers);
00459 
00460   while (!SimpleIVUsers.empty()) {
00461     std::pair<Instruction*, Instruction*> UseOper =
00462       SimpleIVUsers.pop_back_val();
00463     Instruction *UseInst = UseOper.first;
00464 
00465     // Bypass back edges to avoid extra work.
00466     if (UseInst == CurrIV) continue;
00467 
00468     if (V && V->shouldSplitOverflowInstrinsics()) {
00469       UseInst = splitOverflowIntrinsic(UseInst, V->getDomTree());
00470       if (!UseInst)
00471         continue;
00472     }
00473 
00474     Instruction *IVOperand = UseOper.second;
00475     for (unsigned N = 0; IVOperand; ++N) {
00476       assert(N <= Simplified.size() && "runaway iteration");
00477 
00478       Value *NewOper = foldIVUser(UseOper.first, IVOperand);
00479       if (!NewOper)
00480         break; // done folding
00481       IVOperand = dyn_cast<Instruction>(NewOper);
00482     }
00483     if (!IVOperand)
00484       continue;
00485 
00486     if (eliminateIVUser(UseOper.first, IVOperand)) {
00487       pushIVUsers(IVOperand, Simplified, SimpleIVUsers);
00488       continue;
00489     }
00490 
00491     if (BinaryOperator *BO = dyn_cast<BinaryOperator>(UseOper.first)) {
00492       if (isa<OverflowingBinaryOperator>(BO) &&
00493           strengthenOverflowingOperation(BO, IVOperand)) {
00494         // re-queue uses of the now modified binary operator and fall
00495         // through to the checks that remain.
00496         pushIVUsers(IVOperand, Simplified, SimpleIVUsers);
00497       }
00498     }
00499 
00500     CastInst *Cast = dyn_cast<CastInst>(UseOper.first);
00501     if (V && Cast) {
00502       V->visitCast(Cast);
00503       continue;
00504     }
00505     if (isSimpleIVUser(UseOper.first, L, SE)) {
00506       pushIVUsers(UseOper.first, Simplified, SimpleIVUsers);
00507     }
00508   }
00509 }
00510 
00511 namespace llvm {
00512 
00513 void IVVisitor::anchor() { }
00514 
00515 /// Simplify instructions that use this induction variable
00516 /// by using ScalarEvolution to analyze the IV's recurrence.
00517 bool simplifyUsersOfIV(PHINode *CurrIV, ScalarEvolution *SE, LPPassManager *LPM,
00518                        SmallVectorImpl<WeakVH> &Dead, IVVisitor *V)
00519 {
00520   LoopInfo *LI = &LPM->getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
00521   SimplifyIndvar SIV(LI->getLoopFor(CurrIV->getParent()), SE, LI, Dead);
00522   SIV.simplifyUsers(CurrIV, V);
00523   return SIV.hasChanged();
00524 }
00525 
00526 /// Simplify users of induction variables within this
00527 /// loop. This does not actually change or add IVs.
00528 bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, LPPassManager *LPM,
00529                      SmallVectorImpl<WeakVH> &Dead) {
00530   bool Changed = false;
00531   for (BasicBlock::iterator I = L->getHeader()->begin(); isa<PHINode>(I); ++I) {
00532     Changed |= simplifyUsersOfIV(cast<PHINode>(I), SE, LPM, Dead);
00533   }
00534   return Changed;
00535 }
00536 
00537 } // namespace llvm