aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-10-05 05:54:46 +0000
committerChris Lattner <sabre@nondot.org>2009-10-05 05:54:46 +0000
commit82cdc06a6626e9a9fae300fafaeae9702ffb3808 (patch)
tree4ed7b0bdfe761ae52997a152437d00ddaae10360 /lib/VMCore/ConstantFold.cpp
parent4509b017dfea39a23da470417d3abbeab298b79f (diff)
downloadexternal_llvm-82cdc06a6626e9a9fae300fafaeae9702ffb3808.zip
external_llvm-82cdc06a6626e9a9fae300fafaeae9702ffb3808.tar.gz
external_llvm-82cdc06a6626e9a9fae300fafaeae9702ffb3808.tar.bz2
strength reduce a ton of type equality tests to check the typeid (Through
the new predicates I added) instead of going through a context and doing a pointer comparison. Besides being cheaper, this allows a smart compiler to turn the if sequence into a switch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83297 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/ConstantFold.cpp')
-rw-r--r--lib/VMCore/ConstantFold.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 5411549..c1fcc5f 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -192,7 +192,7 @@ Constant *llvm::ConstantFoldCastInstruction(LLVMContext &Context,
return UndefValue::get(DestTy);
}
// No compile-time operations on this type yet.
- if (V->getType() == Type::getPPC_FP128Ty(Context) || DestTy == Type::getPPC_FP128Ty(Context))
+ if (V->getType()->isPPC_FP128Ty() || DestTy->isPPC_FP128Ty())
return 0;
// If the cast operand is a constant expression, there's a few things we can
@@ -241,10 +241,10 @@ Constant *llvm::ConstantFoldCastInstruction(LLVMContext &Context,
if (ConstantFP *FPC = dyn_cast<ConstantFP>(V)) {
bool ignored;
APFloat Val = FPC->getValueAPF();
- Val.convert(DestTy == Type::getFloatTy(Context) ? APFloat::IEEEsingle :
- DestTy == Type::getDoubleTy(Context) ? APFloat::IEEEdouble :
- DestTy == Type::getX86_FP80Ty(Context) ? APFloat::x87DoubleExtended :
- DestTy == Type::getFP128Ty(Context) ? APFloat::IEEEquad :
+ Val.convert(DestTy->isFloatTy() ? APFloat::IEEEsingle :
+ DestTy->isDoubleTy() ? APFloat::IEEEdouble :
+ DestTy->isX86_FP80Ty() ? APFloat::x87DoubleExtended :
+ DestTy->isFP128Ty() ? APFloat::IEEEquad :
APFloat::Bogus,
APFloat::rmNearestTiesToEven, &ignored);
return ConstantFP::get(Context, Val);
@@ -584,7 +584,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(LLVMContext &Context,
unsigned Opcode,
Constant *C1, Constant *C2) {
// No compile-time operations on this type yet.
- if (C1->getType() == Type::getPPC_FP128Ty(Context))
+ if (C1->getType()->isPPC_FP128Ty())
return 0;
// Handle UndefValue up front.
@@ -1110,7 +1110,7 @@ static FCmpInst::Predicate evaluateFCmpRelation(LLVMContext &Context,
"Cannot compare values of different types!");
// No compile-time operations on this type yet.
- if (V1->getType() == Type::getPPC_FP128Ty(Context))
+ if (V1->getType()->isPPC_FP128Ty())
return FCmpInst::BAD_FCMP_PREDICATE;
// Handle degenerate case quickly
@@ -1403,7 +1403,7 @@ Constant *llvm::ConstantFoldCompareInstruction(LLVMContext &Context,
return UndefValue::get(ResultTy);
// No compile-time operations on this type yet.
- if (C1->getType() == Type::getPPC_FP128Ty(Context))
+ if (C1->getType()->isPPC_FP128Ty())
return 0;
// icmp eq/ne(null,GV) -> false/true
@@ -1837,7 +1837,8 @@ Constant *llvm::ConstantFoldGetElementPtr(LLVMContext &Context,
// This happens with pointers to member functions in C++.
if (CE->getOpcode() == Instruction::IntToPtr && NumIdx == 1 &&
isa<ConstantInt>(CE->getOperand(0)) && isa<ConstantInt>(Idxs[0]) &&
- cast<PointerType>(CE->getType())->getElementType() == Type::getInt8Ty(Context)) {
+ cast<PointerType>(CE->getType())->getElementType() ==
+ Type::getInt8Ty(Context)) {
Constant *Base = CE->getOperand(0);
Constant *Offset = Idxs[0];