PHIs.push_back(&PN);
bool Changed = false;
- for (unsigned i = 0, e = PHIs.size(); i != e; ++i)
- if (PHINode *PN = dyn_cast_or_null<PHINode>(&*PHIs[i]))
+ for (WeakTrackingVH &PHI : PHIs)
+ if (PHINode *PN = dyn_cast_or_null<PHINode>(&*PHI))
Changed |= handleFloatingPointIV(L, PN);
// If the loop previously had floating-point IV, ScalarEvolution
// if the direction matrix, after the same permutation is applied to its
// columns, has no ">" direction as the leftmost non-"=" direction in any row.
static bool isLexicographicallyPositive(std::vector<char> &DV) {
- for (unsigned Level = 0; Level < DV.size(); ++Level) {
- unsigned char Direction = DV[Level];
+ for (unsigned char Direction : DV) {
if (Direction == '<')
return true;
if (Direction == '>' || Direction == '*')
LSRInstance::FindUseWithSimilarFormula(const Formula &OrigF,
const LSRUse &OrigLU) {
// Search all uses for the formula. This could be more clever.
- for (size_t LUIdx = 0, NumUses = Uses.size(); LUIdx != NumUses; ++LUIdx) {
- LSRUse &LU = Uses[LUIdx];
+ for (LSRUse &LU : Uses) {
// Check whether this use is close enough to OrigLU, to see whether it's
// worthwhile looking through its formulae.
// Ignore ICmpZero uses because they may contain formulae generated by
// The leaves, repeated according to their weights, represent the linearized
// form of the expression.
- for (unsigned i = 0, e = LeafOrder.size(); i != e; ++i) {
- Value *V = LeafOrder[i];
+ for (Value *V : LeafOrder) {
LeafMap::iterator It = Leaves.find(V);
if (It == Leaves.end())
// Node initially thought to be a leaf wasn't.
// Step 4: Reassemble the Ops
if (Changed) {
Ops.clear();
- for (unsigned int i = 0, e = Opnds.size(); i < e; i++) {
- XorOpnd &O = Opnds[i];
+ for (const XorOpnd &O : Opnds) {
if (O.isInvalid())
continue;
ValueEntry VE(getRank(O.getValue()), O.getValue());
// Add one to FactorOccurrences for each unique factor in this op.
SmallPtrSet<Value*, 8> Duplicates;
- for (unsigned i = 0, e = Factors.size(); i != e; ++i) {
- Value *Factor = Factors[i];
+ for (Value *Factor : Factors) {
if (!Duplicates.insert(Factor).second)
continue;
// Do all the fixups of the original live variables to their relocated selves
SmallVector<Value *, 128> Live;
- for (size_t i = 0; i < Records.size(); i++) {
- PartiallyConstructedSafepointRecord &Info = Records[i];
-
+ for (const PartiallyConstructedSafepointRecord &Info : Records) {
// We can't simply save the live set from the original insertion. One of
// the live values might be the result of a call which needs a safepoint.
// That Value* no longer exists and we need to use the new gc_result.
SmallVector<std::pair<const BasicBlock *, const BasicBlock *>, 32> Edges;
FindFunctionBackedges(F, Edges);
SmallPtrSet<BasicBlock *, 16> UniqueLoopHeaders;
- for (unsigned i = 0, e = Edges.size(); i != e; ++i)
- UniqueLoopHeaders.insert(const_cast<BasicBlock *>(Edges[i].second));
+ for (const auto &Edge : Edges)
+ UniqueLoopHeaders.insert(const_cast<BasicBlock *>(Edge.second));
SmallVector<WeakVH, 16> LoopHeaders(UniqueLoopHeaders.begin(),
UniqueLoopHeaders.end());