//
// The LLVM Compiler Infrastructure
//
-// This file was developed by Nick Lewycky and is distributed under the
-// University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
#include "llvm/Transforms/Utils/Local.h"
#include <algorithm>
#include <deque>
-#include <sstream>
#include <stack>
using namespace llvm;
*Node2 = getNodeForBlock(BB2);
return Node1 && Node2 && Node1->dominates(Node2);
}
+ return false; // Not reached
}
private:
++J;
}
- if (J != E && J->To == n && J->Subtree->dominates(Subtree)) {
+ if (J != E && J->To == n) {
edge.LV = static_cast<LatticeVal>(J->LV & R);
assert(validPredicate(edge.LV) && "Invalid union of lattice values.");
- if (edge.LV != J->LV) {
-
- // We have to tighten any edge beneath our update.
- for (iterator K = I; K->To == n; --K) {
- if (K->Subtree->DominatedBy(Subtree)) {
- LatticeVal LV = static_cast<LatticeVal>(K->LV & edge.LV);
- assert(validPredicate(LV) && "Invalid union of lattice values");
- K->LV = LV;
- }
- if (K == B) break;
- }
+ if (edge.LV == J->LV)
+ return; // This update adds nothing new.
+ }
+
+ if (I != B) {
+ // We also have to tighten any edge beneath our update.
+ for (iterator K = I - 1; K->To == n; --K) {
+ if (K->Subtree->DominatedBy(Subtree)) {
+ LatticeVal LV = static_cast<LatticeVal>(K->LV & edge.LV);
+ assert(validPredicate(LV) && "Invalid union of lattice values");
+ K->LV = LV;
+ }
+ if (K == B) break;
}
}
else if (isa<ConstantPointerNull>(V))
return ConstantRange(APInt::getNullValue(typeToWidth(V->getType())));
else
- return typeToWidth(V->getType());
+ return ConstantRange(typeToWidth(V->getType()));
}
// typeToWidth - returns the number of bits necessary to store a value of
uint32_t typeToWidth(const Type *Ty) const {
if (TD)
return TD->getTypeSizeInBits(Ty);
-
- if (const IntegerType *ITy = dyn_cast<IntegerType>(Ty))
- return ITy->getBitWidth();
-
- return 0;
+ else
+ return Ty->getPrimitiveSizeInBits();
}
static bool isRelatedBy(const ConstantRange &CR1, const ConstantRange &CR2,
if (!Node) return false;
return Top->dominates(Node);
}
+ return false; // Not reached
}
// aboveOrBelow - true if the Instruction either dominates or is dominated
}
// We'd like to allow makeEqual on two values to perform a simple
- // substitution without every creating nodes in the IG whenever possible.
+ // substitution without creating nodes in the IG whenever possible.
//
// The first iteration through this loop operates on V2 before going
// through the Remove list and operating on those too. If all of the
if (mergeIGNode) {
// Create N1.
if (!n1) n1 = VN.getOrInsertVN(V1, Top);
+ IG.node(n1); // Ensure that IG.Nodes won't get resized
// Migrate relationships from removed nodes to N1.
for (SetVector<unsigned>::iterator I = Remove.begin(), E = Remove.end();
if (!isRelatedBy(Known, Zero, ICmpInst::ICMP_NE)) break;
// otherwise, fall-through.
case Instruction::Sub:
- if (Unknown == Op1) break;
+ if (Unknown == Op0) break;
// otherwise, fall-through.
case Instruction::Xor:
case Instruction::Add:
}
}
}
-
- char PredicateSimplifier::ID = 0;
- RegisterPass<PredicateSimplifier> X("predsimplify",
- "Predicate Simplifier");
}
+char PredicateSimplifier::ID = 0;
+static RegisterPass<PredicateSimplifier>
+X("predsimplify", "Predicate Simplifier");
+
FunctionPass *llvm::createPredicateSimplifierPass() {
return new PredicateSimplifier();
}