LLVM: lib/IR/ConstantFold.cpp File Reference (original) (raw)

Go to the source code of this file.

Functions
static unsigned foldConstantCastPair (unsigned opc, ConstantExpr *Op, Type *DstTy)
This function determines which opcode to use to fold two constant cast expressions together.
static Constant * FoldBitCast (Constant *V, Type *DestTy)
static Constant * foldMaybeUndesirableCast (unsigned opc, Constant *V, Type *DestTy)
static ICmpInst::Predicate areGlobalsPotentiallyEqual (const GlobalValue *GV1, const GlobalValue *GV2)
static ICmpInst::Predicate evaluateICmpRelation (Constant *V1, Constant *V2)
This function determines if there is anything we can decide about the two constants provided.

areGlobalsPotentiallyEqual()

evaluateICmpRelation()

This function determines if there is anything we can decide about the two constants provided.

This doesn't need to handle simple things like integer comparisons, but should instead handle ConstantExprs and GlobalValues. If we can determine that the two constants have a particular relation to each other, we should return the corresponding ICmp predicate, otherwise return ICmpInst::BAD_ICMP_PREDICATE.

Definition at line 987 of file ConstantFold.cpp.

References areGlobalsPotentiallyEqual(), assert(), llvm::CmpInst::BAD_ICMP_PREDICATE, llvm::cast(), llvm::dyn_cast(), evaluateICmpRelation(), llvm::User::getOperand(), llvm::CmpInst::getSwappedPredicate(), llvm::Value::getType(), llvm::GEPOperator::hasAllZeroIndices(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_UGT, llvm::isa(), llvm::GEPOperator::isInBounds(), llvm::Type::isPointerTy(), and llvm::NullPointerIsDefined().

Referenced by llvm::ConstantFoldCompareInstruction(), and evaluateICmpRelation().

FoldBitCast()

Definition at line 62 of file ConstantFold.cpp.

References llvm::dyn_cast(), FP, llvm::ConstantVector::get(), llvm::Constant::getAllOnesValue(), llvm::ConstantExpr::getBitCast(), llvm::Type::getFltSemantics(), llvm::Type::getScalarSizeInBits(), llvm::Type::getScalarType(), llvm::isa(), llvm::Type::isFPOrFPVectorTy(), llvm::Type::isIntOrIntVectorTy(), and llvm::Type::isPPC_FP128Ty().

Referenced by llvm::ConstantFoldCastInstruction(), and llvm::ConstantFoldCastOperand().

foldConstantCastPair()

foldMaybeUndesirableCast()