aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-06-10 02:12:35 +0000
committerChris Lattner <sabre@nondot.org>2004-06-10 02:12:35 +0000
commit448c323cba87fa8a0f8b306af26fe0055682959d (patch)
treef854b3cb29e487a45dcc2de5bd2884ce2fafa1b7 /lib
parent48595f18cf5a78de8539a0a85b29e65871e5cdd8 (diff)
downloadexternal_llvm-448c323cba87fa8a0f8b306af26fe0055682959d.zip
external_llvm-448c323cba87fa8a0f8b306af26fe0055682959d.tar.gz
external_llvm-448c323cba87fa8a0f8b306af26fe0055682959d.tar.bz2
More minor cleanups
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14108 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index c15e935..e627392 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -304,22 +304,17 @@ static inline Value *dyn_castNegVal(Value *V) {
// Constants can be considered to be negated values if they can be folded...
if (Constant *C = dyn_cast<Constant>(V))
- return ConstantExpr::getSub(Constant::getNullValue(V->getType()), C);
+ return ConstantExpr::getNeg(C);
return 0;
}
-static Constant *NotConstant(Constant *C) {
- return ConstantExpr::getXor(C,
- ConstantIntegral::getAllOnesValue(C->getType()));
-}
-
static inline Value *dyn_castNotVal(Value *V) {
if (BinaryOperator::isNot(V))
return BinaryOperator::getNotArgument(cast<BinaryOperator>(V));
// Constants can be considered to be not'ed values...
if (ConstantIntegral *C = dyn_cast<ConstantIntegral>(V))
- return NotConstant(C);
+ return ConstantExpr::getNot(C);
return 0;
}
@@ -1212,7 +1207,8 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
Op0Name);
InsertNewInstBefore(Or, I);
return BinaryOperator::createXor(Or,
- ConstantExpr::getAnd(Op0CI, NotConstant(RHS)));
+ ConstantExpr::getAnd(Op0CI,
+ ConstantExpr::getNot(RHS)));
}
}
@@ -1320,7 +1316,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
case Instruction::Or:
// (X | C1) ^ C2 --> (X | C1) & ~C2 iff (C1&C2) == C2
if (ConstantExpr::getAnd(RHS, Op0CI) == RHS)
- return BinaryOperator::createAnd(Op0, NotConstant(RHS));
+ return BinaryOperator::createAnd(Op0, ConstantExpr::getNot(RHS));
break;
default: break;
}
@@ -1571,7 +1567,7 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
// If bits are being or'd in that are not present in the constant we
// are comparing against, then the comparison could never succeed!
if (Constant *BOC = dyn_cast<Constant>(BO->getOperand(1))) {
- Constant *NotCI = NotConstant(CI);
+ Constant *NotCI = ConstantExpr::getNot(CI);
if (!ConstantExpr::getAnd(BOC, NotCI)->isNullValue())
return ReplaceInstUsesWith(I, ConstantBool::get(isSetNE));
}
@@ -1581,7 +1577,8 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
if (ConstantInt *BOC = dyn_cast<ConstantInt>(BO->getOperand(1))) {
// If bits are being compared against that are and'd out, then the
// comparison can never succeed!
- if (!ConstantExpr::getAnd(CI, NotConstant(BOC))->isNullValue())
+ if (!ConstantExpr::getAnd(CI,
+ ConstantExpr::getNot(BOC))->isNullValue())
return ReplaceInstUsesWith(I, ConstantBool::get(isSetNE));
// If we have ((X & C) == C), turn it into ((X & C) != 0).