mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +00:00
InstCombine: Hoist 3 copies of AddOne/SubOne into a header.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199605 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -51,6 +51,15 @@ static inline unsigned getComplexity(Value *V) {
|
|||||||
return isa<Constant>(V) ? (isa<UndefValue>(V) ? 0 : 1) : 2;
|
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
|
/// InstCombineIRInserter - This is an IRBuilder insertion helper that works
|
||||||
/// just like the normal insertion helper, but also adds any new instructions
|
/// just like the normal insertion helper, but also adds any new instructions
|
||||||
|
|||||||
@@ -845,17 +845,6 @@ Value *FAddCombine::createAddendVal
|
|||||||
return createFMul(OpndVal, Coeff.getValue(Instr->getType()));
|
return createFMul(OpndVal, Coeff.getValue(Instr->getType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// AddOne - Add one to a ConstantInt.
|
|
||||||
static Constant *AddOne(Constant *C) {
|
|
||||||
return ConstantExpr::getAdd(C, ConstantInt::get(C->getType(), 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// SubOne - Subtract one from a ConstantInt.
|
|
||||||
static Constant *SubOne(Constant *C) {
|
|
||||||
return ConstantExpr::getAdd(C, ConstantInt::getAllOnesValue(C->getType()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// dyn_castFoldableMul - If this value is a multiply that can be folded into
|
// dyn_castFoldableMul - If this value is a multiply that can be folded into
|
||||||
// other computations (because it has a constant operand), return the
|
// other computations (because it has a constant operand), return the
|
||||||
// non-constant operand of the multiply, and set CST to point to the multiplier.
|
// non-constant operand of the multiply, and set CST to point to the multiplier.
|
||||||
|
|||||||
@@ -20,16 +20,6 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace PatternMatch;
|
using namespace PatternMatch;
|
||||||
|
|
||||||
|
|
||||||
/// AddOne - Add one to a ConstantInt.
|
|
||||||
static Constant *AddOne(ConstantInt *C) {
|
|
||||||
return ConstantInt::get(C->getContext(), C->getValue() + 1);
|
|
||||||
}
|
|
||||||
/// SubOne - Subtract one from a ConstantInt.
|
|
||||||
static Constant *SubOne(ConstantInt *C) {
|
|
||||||
return ConstantInt::get(C->getContext(), C->getValue()-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// isFreeToInvert - Return true if the specified value is free to invert (apply
|
/// isFreeToInvert - Return true if the specified value is free to invert (apply
|
||||||
/// ~ to). This happens in cases where the ~ can be eliminated.
|
/// ~ to). This happens in cases where the ~ can be eliminated.
|
||||||
static inline bool isFreeToInvert(Value *V) {
|
static inline bool isFreeToInvert(Value *V) {
|
||||||
|
|||||||
@@ -28,15 +28,6 @@ static ConstantInt *getOne(Constant *C) {
|
|||||||
return ConstantInt::get(cast<IntegerType>(C->getType()), 1);
|
return ConstantInt::get(cast<IntegerType>(C->getType()), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// AddOne - Add one to a ConstantInt
|
|
||||||
static Constant *AddOne(Constant *C) {
|
|
||||||
return ConstantExpr::getAdd(C, ConstantInt::get(C->getType(), 1));
|
|
||||||
}
|
|
||||||
/// SubOne - Subtract one from a ConstantInt
|
|
||||||
static Constant *SubOne(Constant *C) {
|
|
||||||
return ConstantExpr::getSub(C, ConstantInt::get(C->getType(), 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
static ConstantInt *ExtractElement(Constant *V, Constant *Idx) {
|
static ConstantInt *ExtractElement(Constant *V, Constant *Idx) {
|
||||||
return cast<ConstantInt>(ConstantExpr::getExtractElement(V, Idx));
|
return cast<ConstantInt>(ConstantExpr::getExtractElement(V, Idx));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user