InstCombine: Hoist 3 copies of AddOne/SubOne into a header.
[oota-llvm.git] / lib / Transforms / InstCombine / InstCombine.h
index ca834c109403bcce40058d5287db8895fd17669d..4021f292d970e2d25a9b7fa1450f6cffd05b90a9 100644 (file)
@@ -51,6 +51,15 @@ static inline unsigned getComplexity(Value *V) {
   return isa<Constant>(V) ? (isa<UndefValue>(V) ? 0 : 1) : 2;
 }
 
+/// AddOne - Add one to a Constant
+static inline Constant *AddOne(Constant *C) {
+  return ConstantExpr::getAdd(C, ConstantInt::get(C->getType(), 1));
+}
+/// SubOne - Subtract one from a Constant
+static inline Constant *SubOne(Constant *C) {
+  return ConstantExpr::getSub(C, ConstantInt::get(C->getType(), 1));
+}
+
 
 /// InstCombineIRInserter - This is an IRBuilder insertion helper that works
 /// just like the normal insertion helper, but also adds any new instructions