aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2008-02-20 11:08:44 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2008-02-20 11:08:44 +0000
commitae9f3a3b7c915f725aef5a7250e88eaeddda03c6 (patch)
treeb32dad9e6075f8f292819f06d26e306fc94427a0 /lib/VMCore/ConstantFold.cpp
parent6d794746b7ae1ed531f08c04dd29d79c13b35075 (diff)
downloadexternal_llvm-ae9f3a3b7c915f725aef5a7250e88eaeddda03c6.zip
external_llvm-ae9f3a3b7c915f725aef5a7250e88eaeddda03c6.tar.gz
external_llvm-ae9f3a3b7c915f725aef5a7250e88eaeddda03c6.tar.bz2
Unbreak build with gcc 4.3: provide missed includes and silence most annoying warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47367 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/ConstantFold.cpp')
-rw-r--r--lib/VMCore/ConstantFold.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 06dc9dc..451190f 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -660,25 +660,28 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
case Instruction::Xor:
return ConstantInt::get(C1V ^ C2V);
case Instruction::Shl:
- if (uint32_t shiftAmt = C2V.getZExtValue())
+ if (uint32_t shiftAmt = C2V.getZExtValue()) {
if (shiftAmt < C1V.getBitWidth())
return ConstantInt::get(C1V.shl(shiftAmt));
else
return UndefValue::get(C1->getType()); // too big shift is undef
+ }
return const_cast<ConstantInt*>(CI1); // Zero shift is identity
case Instruction::LShr:
- if (uint32_t shiftAmt = C2V.getZExtValue())
+ if (uint32_t shiftAmt = C2V.getZExtValue()) {
if (shiftAmt < C1V.getBitWidth())
return ConstantInt::get(C1V.lshr(shiftAmt));
else
return UndefValue::get(C1->getType()); // too big shift is undef
+ }
return const_cast<ConstantInt*>(CI1); // Zero shift is identity
case Instruction::AShr:
- if (uint32_t shiftAmt = C2V.getZExtValue())
+ if (uint32_t shiftAmt = C2V.getZExtValue()) {
if (shiftAmt < C1V.getBitWidth())
return ConstantInt::get(C1V.ashr(shiftAmt));
else
return UndefValue::get(C1->getType()); // too big shift is undef
+ }
return const_cast<ConstantInt*>(CI1); // Zero shift is identity
}
}
@@ -1083,18 +1086,20 @@ static ICmpInst::Predicate evaluateICmpRelation(const Constant *V1,
// Ok, we ran out of things they have in common. If any leftovers
// are non-zero then we have a difference, otherwise we are equal.
for (; i < CE1->getNumOperands(); ++i)
- if (!CE1->getOperand(i)->isNullValue())
+ if (!CE1->getOperand(i)->isNullValue()) {
if (isa<ConstantInt>(CE1->getOperand(i)))
return isSigned ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
else
return ICmpInst::BAD_ICMP_PREDICATE; // Might be equal.
+ }
for (; i < CE2->getNumOperands(); ++i)
- if (!CE2->getOperand(i)->isNullValue())
+ if (!CE2->getOperand(i)->isNullValue()) {
if (isa<ConstantInt>(CE2->getOperand(i)))
return isSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT;
else
return ICmpInst::BAD_ICMP_PREDICATE; // Might be equal.
+ }
return ICmpInst::ICMP_EQ;
}
}
@@ -1123,20 +1128,22 @@ Constant *llvm::ConstantFoldCompareInstruction(unsigned short pred,
if (C1->isNullValue()) {
if (const GlobalValue *GV = dyn_cast<GlobalValue>(C2))
// Don't try to evaluate aliases. External weak GV can be null.
- if (!isa<GlobalAlias>(GV) && !GV->hasExternalWeakLinkage())
+ if (!isa<GlobalAlias>(GV) && !GV->hasExternalWeakLinkage()) {
if (pred == ICmpInst::ICMP_EQ)
return ConstantInt::getFalse();
else if (pred == ICmpInst::ICMP_NE)
return ConstantInt::getTrue();
+ }
// icmp eq/ne(GV,null) -> false/true
} else if (C2->isNullValue()) {
if (const GlobalValue *GV = dyn_cast<GlobalValue>(C1))
// Don't try to evaluate aliases. External weak GV can be null.
- if (!isa<GlobalAlias>(GV) && !GV->hasExternalWeakLinkage())
+ if (!isa<GlobalAlias>(GV) && !GV->hasExternalWeakLinkage()) {
if (pred == ICmpInst::ICMP_EQ)
return ConstantInt::getFalse();
else if (pred == ICmpInst::ICMP_NE)
return ConstantInt::getTrue();
+ }
}
if (isa<ConstantInt>(C1) && isa<ConstantInt>(C2)) {