|
LLVM
10.0.0
|
#include "InstCombineInternal.h"#include "llvm-c/Initialization.h"#include "llvm-c/Transforms/InstCombine.h"#include "llvm/ADT/APInt.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/DenseMap.h"#include "llvm/ADT/None.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/ADT/TinyPtrVector.h"#include "llvm/Analysis/AliasAnalysis.h"#include "llvm/Analysis/AssumptionCache.h"#include "llvm/Analysis/BasicAliasAnalysis.h"#include "llvm/Analysis/BlockFrequencyInfo.h"#include "llvm/Analysis/CFG.h"#include "llvm/Analysis/ConstantFolding.h"#include "llvm/Analysis/EHPersonalities.h"#include "llvm/Analysis/GlobalsModRef.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/Analysis/LazyBlockFrequencyInfo.h"#include "llvm/Analysis/LoopInfo.h"#include "llvm/Analysis/MemoryBuiltins.h"#include "llvm/Analysis/OptimizationRemarkEmitter.h"#include "llvm/Analysis/ProfileSummaryInfo.h"#include "llvm/Analysis/TargetFolder.h"#include "llvm/Analysis/TargetLibraryInfo.h"#include "llvm/Analysis/ValueTracking.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/CFG.h"#include "llvm/IR/Constant.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DIBuilder.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/DerivedTypes.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/Function.h"#include "llvm/IR/GetElementPtrTypeIterator.h"#include "llvm/IR/IRBuilder.h"#include "llvm/IR/InstrTypes.h"#include "llvm/IR/Instruction.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Intrinsics.h"#include "llvm/IR/LegacyPassManager.h"#include "llvm/IR/Metadata.h"#include "llvm/IR/Operator.h"#include "llvm/IR/PassManager.h"#include "llvm/IR/PatternMatch.h"#include "llvm/IR/Type.h"#include "llvm/IR/Use.h"#include "llvm/IR/User.h"#include "llvm/IR/Value.h"#include "llvm/IR/ValueHandle.h"#include "llvm/InitializePasses.h"#include "llvm/Pass.h"#include "llvm/Support/CBindingWrapping.h"#include "llvm/Support/Casting.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Compiler.h"#include "llvm/Support/Debug.h"#include "llvm/Support/DebugCounter.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Support/KnownBits.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/InstCombine/InstCombine.h"#include "llvm/Transforms/InstCombine/InstCombineWorklist.h"#include "llvm/Transforms/Utils/Local.h"#include <algorithm>#include <cassert>#include <cstdint>#include <memory>#include <string>#include <utility>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "instcombine" |
Functions | |
| STATISTIC (NumCombined, "Number of insts combined") | |
| STATISTIC (NumConstProp, "Number of constant folds") | |
| STATISTIC (NumDeadInst, "Number of dead inst eliminated") | |
| STATISTIC (NumSunkInst, "Number of instructions sunk") | |
| STATISTIC (NumExpand, "Number of expansions") | |
| STATISTIC (NumFactor, "Number of factorizations") | |
| STATISTIC (NumReassoc, "Number of reassociations") | |
| DEBUG_COUNTER (VisitCounter, "instcombine-visit", "Controls which instructions are visited") | |
| static bool | maintainNoSignedWrap (BinaryOperator &I, Value *B, Value *C) |
| static bool | hasNoUnsignedWrap (BinaryOperator &I) |
| static bool | hasNoSignedWrap (BinaryOperator &I) |
| static void | ClearSubclassDataAfterReassociation (BinaryOperator &I) |
| Conservatively clears subclassOptionalData after a reassociation or commutation. More... | |
| static bool | simplifyAssocCastAssoc (BinaryOperator *BinOp1) |
| Combine constant operands of associative operations either before or after a cast to eliminate one of the associative operations: (op (cast (op X, C2)), C1) –> (cast (op X, op (C1, C2))) (op (cast (op X, C2)), C1) –> (op (cast X), op (C1, C2)) More... | |
| static bool | leftDistributesOverRight (Instruction::BinaryOps LOp, Instruction::BinaryOps ROp) |
| Return whether "X LOp (Y ROp Z)" is always equal to "(X LOp Y) ROp (X LOp Z)". More... | |
| static bool | rightDistributesOverLeft (Instruction::BinaryOps LOp, Instruction::BinaryOps ROp) |
| Return whether "(X LOp Y) ROp Z" is always equal to "(X ROp Z) LOp (Y ROp Z)". More... | |
| static Value * | getIdentityValue (Instruction::BinaryOps Opcode, Value *V) |
| This function returns identity value for given opcode, which can be used to factor patterns like (X * 2) + X ==> (X * 2) + (X * 1) ==> X * (2 + 1). More... | |
| static Instruction::BinaryOps | getBinOpsForFactorization (Instruction::BinaryOps TopOpcode, BinaryOperator *Op, Value *&LHS, Value *&RHS) |
| This function predicates factorization using distributive laws. More... | |
| static Value * | foldOperationIntoSelectOperand (Instruction &I, Value *SO, InstCombiner::BuilderTy &Builder) |
| static Value * | foldOperationIntoPhiValue (BinaryOperator *I, Value *InV, InstCombiner::BuilderTy &Builder) |
| static bool | shouldMergeGEPs (GEPOperator &GEP, GEPOperator &Src) |
| static bool | isMergedGEPInBounds (GEPOperator &GEP1, GEPOperator &GEP2) |
| static bool | isNeverEqualToUnescapedAlloc (Value *V, const TargetLibraryInfo *TLI, Instruction *AI) |
| static bool | isAllocSiteRemovable (Instruction *AI, SmallVectorImpl< WeakTrackingVH > &Users, const TargetLibraryInfo *TLI) |
| static Instruction * | tryToMoveFreeBeforeNullTest (CallInst &FI, const DataLayout &DL) |
| Move the call to free before a NULL test. More... | |
| static bool | isCatchAll (EHPersonality Personality, Constant *TypeInfo) |
| Return 'true' if the given typeinfo will match anything. More... | |
| static bool | shorter_filter (const Value *LHS, const Value *RHS) |
| static bool | TryToSinkInstruction (Instruction *I, BasicBlock *DestBlock) |
| Try to move the specified instruction from its current block into the beginning of DestBlock, which can only happen if it's safe to move the instruction past all of the instructions between it and the end of its block. More... | |
| static bool | AddReachableCodeToWorklist (BasicBlock *BB, const DataLayout &DL, SmallPtrSetImpl< BasicBlock *> &Visited, InstCombineWorklist &ICWorklist, const TargetLibraryInfo *TLI) |
| Walk the function in depth-first order, adding all reachable code to the worklist. More... | |
| static bool | prepareICWorklistFromFunction (Function &F, const DataLayout &DL, TargetLibraryInfo *TLI, InstCombineWorklist &ICWorklist) |
| Populate the IC worklist from a function, and prune any dead basic blocks discovered in the process. More... | |
| static bool | combineInstructionsOverFunction (Function &F, InstCombineWorklist &Worklist, AliasAnalysis *AA, AssumptionCache &AC, TargetLibraryInfo &TLI, DominatorTree &DT, OptimizationRemarkEmitter &ORE, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI, bool ExpensiveCombines, unsigned MaxIterations, LoopInfo *LI) |
| INITIALIZE_PASS_BEGIN (InstructionCombiningPass, "instcombine", "Combine redundant instructions", false, false) INITIALIZE_PASS_END(InstructionCombiningPass | |
| void | LLVMInitializeInstCombine (LLVMPassRegistryRef R) |
| void | LLVMAddInstructionCombiningPass (LLVMPassManagerRef PM) |
| See llvm::createInstructionCombiningPass function. More... | |
Variables | |
| static constexpr unsigned | InstCombineDefaultMaxIterations = 1000 |
| static constexpr unsigned | InstCombineDefaultInfiniteLoopThreshold = 1000 |
| static cl::opt< bool > | EnableCodeSinking ("instcombine-code-sinking", cl::desc("Enable code sinking"), cl::init(true)) |
| static cl::opt< bool > | EnableExpensiveCombines ("expensive-combines", cl::desc("Enable expensive instruction combines")) |
| static cl::opt< unsigned > | LimitMaxIterations ("instcombine-max-iterations", cl::desc("Limit the maximum number of instruction combining iterations"), cl::init(InstCombineDefaultMaxIterations)) |
| static cl::opt< unsigned > | InfiniteLoopDetectionThreshold ("instcombine-infinite-loop-threshold", cl::desc("Number of instruction combining iterations considered an " "infinite loop"), cl::init(InstCombineDefaultInfiniteLoopThreshold), cl::Hidden) |
| static cl::opt< unsigned > | MaxArraySize ("instcombine-maxarray-size", cl::init(1024), cl::desc("Maximum array size considered when doing a combine")) |
| static cl::opt< unsigned > | ShouldLowerDbgDeclare ("instcombine-lower-dbg-declare", cl::Hidden, cl::init(true)) |
| instcombine | |
| Combine redundant | instructions |
| Combine redundant | false |
| #define DEBUG_TYPE "instcombine" |
Definition at line 113 of file InstructionCombining.cpp.
|
static |
Walk the function in depth-first order, adding all reachable code to the worklist.
This has a couple of tricks to make the code faster and more powerful. In particular, we constant fold and DCE instructions as we go, to avoid adding them to the worklist (this significantly speeds up instcombine on code where many instructions are dead or constant). Additionally, if we find a branch whose condition is a known constant, we only visit the reachable successors.
Definition at line 3429 of file InstructionCombining.cpp.
References llvm::BasicBlock::begin(), C, llvm::ConstantFoldConstant(), llvm::ConstantFoldInstruction(), llvm::dbgs(), E, llvm::BasicBlock::end(), llvm::Instruction::eraseFromParent(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::BasicBlock::getTerminator(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isInstructionTriviallyDead(), LLVM_DEBUG, llvm::User::operands(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::salvageDebugInfoOrMarkUndef(), and llvm::Value::use_empty().
Referenced by prepareICWorklistFromFunction().
|
static |
Conservatively clears subclassOptionalData after a reassociation or commutation.
We preserve fast-math flags when applicable as they can be preserved.
Definition at line 254 of file InstructionCombining.cpp.
References llvm::Value::clearSubclassOptionalData(), llvm::dyn_cast(), llvm::Instruction::getFastMathFlags(), I, and llvm::Instruction::setFastMathFlags().
Referenced by simplifyAssocCastAssoc().
|
static |
Builder - This is an IRBuilder that automatically inserts new instructions into the worklist when they are created.
Definition at line 3564 of file InstructionCombining.cpp.
References llvm::InstCombineWorklist::Add(), llvm::AMDGPUISD::BFI, llvm::dbgs(), EnableExpensiveCombines, llvm::Function::getContext(), llvm::Module::getDataLayout(), llvm::Value::getName(), llvm::GlobalValue::getParent(), llvm::Function::hasMinSize(), InfiniteLoopDetectionThreshold, LimitMaxIterations, LLVM_DEBUG, llvm::LowerDbgDeclare(), llvm::PatternMatch::match(), MaxArraySize, llvm::InstCombiner::MaxArraySizeForCombine, prepareICWorklistFromFunction(), llvm::AssumptionCache::registerAssumption(), llvm::report_fatal_error(), and ShouldLowerDbgDeclare.
Referenced by llvm::InstCombinePass::run(), and llvm::InstructionCombiningPass::runOnFunction().
| DEBUG_COUNTER | ( | VisitCounter | , |
| "instcombine-visit" | , | ||
| "Controls which instructions are visited" | |||
| ) |
|
static |
Definition at line 939 of file InstructionCombining.cpp.
References llvm::PHINode::addIncoming(), assert(), C, llvm::Instruction::copyFastMathFlags(), llvm::PHINode::Create(), llvm::IRBuilder< T, Inserter >::CreateBinOp(), llvm::Value::DoPHITranslation(), llvm::dyn_cast(), E, llvm::ConstantInt::get(), llvm::ConstantExpr::get(), llvm::ConstantExpr::getCast(), llvm::ConstantExpr::getCompare(), llvm::Type::getContext(), llvm::StructLayout::getElementContainingOffset(), llvm::StructLayout::getElementOffset(), llvm::PointerType::getElementType(), llvm::SelectInst::getFalseValue(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::Type::getInt32Ty(), llvm::PHINode::getNumIncomingValues(), llvm::BinaryOperator::getOpcode(), llvm::CastInst::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), getParent(), llvm::StructLayout::getSizeInBytes(), llvm::BasicBlock::getTerminator(), llvm::SelectInst::getTrueValue(), llvm::Value::getType(), llvm::Value::hasOneUse(), I, llvm::Instruction::isIdenticalTo(), llvm::Constant::isNullValue(), llvm::isPotentiallyReachable(), llvm::Type::isSized(), llvm::BranchInst::isUnconditional(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), std::swap(), llvm::Value::takeName(), llvm::Value::user_begin(), llvm::Value::user_end(), and llvm::Value::users().
|
static |
Definition at line 859 of file InstructionCombining.cpp.
References assert(), llvm::Instruction::copyFastMathFlags(), llvm::SelectInst::Create(), llvm::IRBuilder< T, Inserter >::CreateBinOp(), llvm::IRBuilder< T, Inserter >::CreateCast(), llvm::dyn_cast(), llvm::ConstantExpr::get(), llvm::SelectInst::getCondition(), llvm::SelectInst::getFalseValue(), llvm::Value::getName(), llvm::SequentialType::getNumElements(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::SelectInst::getTrueValue(), llvm::Value::getType(), llvm::Value::hasOneUse(), I, llvm::Instruction::isBinaryOp(), llvm::Type::isIntOrIntVectorTy(), SI, and std::swap().
|
static |
This function predicates factorization using distributive laws.
By default, it just returns the 'Op' inputs. But for special-cases like 'add(shl(X, 5), ...)', this function will have TopOpcode == Instruction::Add and Op = shl(X, 5). The 'shl' is treated as the more general 'mul X, 32' to allow more factorization opportunities.
Definition at line 537 of file InstructionCombining.cpp.
References llvm::MCID::Add, assert(), B, C, D, llvm::dyn_cast(), E, F(), llvm::ConstantInt::get(), llvm::ConstantExpr::getBinOpIdentity(), llvm::Instruction::getFastMathFlags(), getIdentityValue(), llvm::Value::getName(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::ConstantExpr::getShl(), llvm::Value::getType(), llvm::SimplifyQuery::getWithInstruction(), llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), llvm::Instruction::isCommutative(), llvm::APInt::isMinSignedValue(), leftDistributesOverRight(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Select(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), rightDistributesOverLeft(), llvm::SimplifyBinOp(), std::swap(), and llvm::Value::takeName().
|
static |
This function returns identity value for given opcode, which can be used to factor patterns like (X * 2) + X ==> (X * 2) + (X * 1) ==> X * (2 + 1).
Definition at line 524 of file InstructionCombining.cpp.
References llvm::ConstantExpr::getBinOpIdentity(), and llvm::Value::getType().
Referenced by getBinOpsForFactorization().
|
static |
Definition at line 246 of file InstructionCombining.cpp.
References llvm::dyn_cast(), llvm::OverflowingBinaryOperator::hasNoSignedWrap(), and I.
Referenced by llvm::InstCombiner::commonIDivTransforms(), ConvertShiftToMul(), llvm::Instruction::getDebugLoc(), llvm::PHITransAddr::PHITranslateWithInsertion(), llvm::SDNode::print_details(), propagateMetadata(), RemoveInstInputs(), ShrinkDemandedConstant(), simplifyAssocCastAssoc(), and llvm::InstCombiner::visitMul().
|
static |
Definition at line 241 of file InstructionCombining.cpp.
References llvm::dyn_cast(), llvm::OverflowingBinaryOperator::hasNoUnsignedWrap(), and I.
Referenced by llvm::InstCombiner::commonIDivTransforms(), ConvertShiftToMul(), llvm::Instruction::getDebugLoc(), isPromotedResultSafe(), llvm::PHITransAddr::PHITranslateWithInsertion(), llvm::SDNode::print_details(), propagateMetadata(), RemoveInstInputs(), simplifyAssocCastAssoc(), and llvm::InstCombiner::visitLShr().
| INITIALIZE_PASS_BEGIN | ( | InstructionCombiningPass | , |
| "instcombine" | , | ||
| "Combine redundant instructions" | , | ||
| false | , | ||
| false | |||
| ) |
Referenced by llvm::InstructionCombiningPass::InstructionCombiningPass().
|
static |
Definition at line 2321 of file InstructionCombining.cpp.
References llvm::MCID::Call, llvm::SmallVectorImpl< T >::emplace_back(), llvm::SmallVectorBase::empty(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::StoreInst::getPointerOperand(), llvm::MemIntrinsicBase< Derived >::getRawDest(), I, llvm::ICmpInst::isEquality(), llvm::isFreeCall(), isNeverEqualToUnescapedAlloc(), llvm::StoreInst::isVolatile(), llvm::MemIntrinsic::isVolatile(), LLVM_FALLTHROUGH, llvm_unreachable, MI, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::SPII::Store, and llvm::Value::users().
Referenced by llvm::InstCombiner::visitAllocSite().
|
static |
Return 'true' if the given typeinfo will match anything.
Definition at line 2821 of file InstructionCombining.cpp.
References llvm::CoreCLR, llvm::GNU_Ada, llvm::GNU_C, llvm::GNU_C_SjLj, llvm::GNU_CXX, llvm::GNU_CXX_SjLj, llvm::GNU_ObjC, llvm::Constant::isNullValue(), llvm_unreachable, llvm::MSVC_CXX, llvm::MSVC_Win64SEH, llvm::MSVC_X86SEH, llvm::Rust, llvm::Unknown, and llvm::Wasm_CXX.
Referenced by llvm::InstCombiner::visitLandingPadInst().
|
static |
Definition at line 1652 of file InstructionCombining.cpp.
References llvm::GEPOperator::hasAllZeroIndices(), and llvm::GEPOperator::isInBounds().
Referenced by llvm::InstCombiner::visitGetElementPtrInst().
|
static |
Definition at line 2307 of file InstructionCombining.cpp.
References llvm::isAllocLikeFn().
Referenced by isAllocSiteRemovable().
|
static |
Return whether "X LOp (Y ROp Z)" is always equal to "(X LOp Y) ROp (X LOp Z)".
Definition at line 488 of file InstructionCombining.cpp.
References llvm::MCID::Add.
Referenced by getBinOpsForFactorization(), and rightDistributesOverLeft().
|
static |
Definition at line 218 of file InstructionCombining.cpp.
References llvm::MCID::Add, llvm::dyn_cast(), llvm::BinaryOperator::getOpcode(), I, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), llvm::APInt::sadd_ov(), and llvm::APInt::ssub_ov().
Referenced by simplifyAssocCastAssoc().
|
static |
Populate the IC worklist from a function, and prune any dead basic blocks discovered in the process.
This also does basic constant propagation and other forward fixing to make the combiner itself run much faster.
Definition at line 3537 of file InstructionCombining.cpp.
References AddReachableCodeToWorklist(), llvm::Function::front(), and llvm::removeAllNonTerminatorAndEHPadInstructions().
Referenced by combineInstructionsOverFunction().
|
static |
Return whether "(X LOp Y) ROp Z" is always equal to "(X ROp Z) LOp (Y ROp Z)".
Definition at line 509 of file InstructionCombining.cpp.
References llvm::Instruction::isBitwiseLogicOp(), llvm::Instruction::isCommutative(), llvm::Instruction::isShift(), and leftDistributesOverRight().
Referenced by getBinOpsForFactorization().
Definition at line 2848 of file InstructionCombining.cpp.
References llvm::Value::getType().
Referenced by llvm::InstCombiner::visitLandingPadInst().
|
static |
Definition at line 1182 of file InstructionCombining.cpp.
References assert(), C, llvm::Instruction::copyIRFlags(), llvm::BinaryOperator::Create(), llvm::CastInst::Create(), llvm::APInt::exactLogBase2(), llvm::ConstantInt::get(), llvm::ConstantVector::get(), llvm::ConstantExpr::get(), llvm::UndefValue::get(), llvm::Constant::getAggregateElement(), getBitWidth(), llvm::APInt::getBitWidth(), llvm::ConstantExpr::getCast(), llvm::Instruction::getOpcode(), getOpcode(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::getSafeVectorConstantForBinop(), llvm::Type::getScalarType(), llvm::ShuffleVectorInst::getShuffleMask(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::GEPOperator::hasAllZeroIndices(), llvm::Instruction::hasNoSignedWrap(), hasOneUse(), llvm::Value::hasOneUse(), I, llvm::Instruction::isCommutative(), llvm::Instruction::isIntDivRem(), llvm::APInt::isMinValue(), llvm::isSafeToSpeculativelyExecute(), llvm::Instruction::isShift(), llvm::Type::isVectorTy(), llvm::PatternMatch::m_c_BinOp(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_ShuffleVector(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Undef(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), llvm::APInt::sdivrem(), llvm::APInt::sext(), std::swap(), llvm::APInt::trunc(), llvm::Instruction::user_back(), llvm::NVPTX::PTXLdStInstCode::V2, willNotOverflow(), X, and Y.
Referenced by llvm::InstCombiner::visitGetElementPtrInst().
|
static |
Combine constant operands of associative operations either before or after a cast to eliminate one of the associative operations: (op (cast (op X, C2)), C1) –> (cast (op X, op (C1, C2))) (op (cast (op X, C2)), C1) –> (op (cast X), op (C1, C2))
Definition at line 270 of file InstructionCombining.cpp.
References llvm::MCID::Add, B, C, ClearSubclassDataAfterReassociation(), llvm::BinaryOperator::Create(), llvm::BinaryOperator::CreateNUW(), llvm::dyn_cast(), llvm::ConstantExpr::get(), llvm::ConstantExpr::getCast(), llvm::getComplexity(), llvm::Instruction::getFastMathFlags(), llvm::BinaryOperator::getOpcode(), llvm::CastInst::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), hasNoSignedWrap(), hasNoUnsignedWrap(), I, llvm::Instruction::isAssociative(), llvm::Instruction::isBitwiseLogicOp(), llvm::Instruction::isCommutative(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), maintainNoSignedWrap(), llvm::PatternMatch::match(), llvm::Instruction::setFastMathFlags(), llvm::Instruction::setHasNoSignedWrap(), llvm::Instruction::setHasNoUnsignedWrap(), llvm::User::setOperand(), llvm::SimplifyBinOp(), llvm::BinaryOperator::swapOperands(), and llvm::Value::takeName().
| STATISTIC | ( | NumCombined | , |
| "Number of insts combined" | |||
| ) |
| STATISTIC | ( | NumConstProp | , |
| "Number of constant folds" | |||
| ) |
| STATISTIC | ( | NumDeadInst | , |
| "Number of dead inst eliminated" | |||
| ) |
| STATISTIC | ( | NumSunkInst | , |
| "Number of instructions sunk" | |||
| ) |
| STATISTIC | ( | NumExpand | , |
| "Number of expansions" | |||
| ) |
| STATISTIC | ( | NumFactor | , |
| "Number of factorizations" | |||
| ) |
| STATISTIC | ( | NumReassoc | , |
| "Number of reassociations" | |||
| ) |
|
static |
Move the call to free before a NULL test.
Check if this free is accessed after its argument has been test against NULL (property 0). If yes, it is legal to move this call in its predecessor block.
The move is performed only if the block containing the call to free will be removed, i.e.:
The profitability is out-of concern here and this function should be called only if the caller knows this transformation would be profitable (e.g., for code size).
Definition at line 2495 of file InstructionCombining.cpp.
References assert(), llvm::BasicBlock::begin(), llvm::dyn_cast(), llvm::CallBase::getArgOperand(), llvm::Instruction::getParent(), llvm::BasicBlock::getSinglePredecessor(), llvm::BasicBlock::getTerminator(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::PatternMatch::m_Br(), llvm::PatternMatch::m_CombineOr(), llvm::PatternMatch::m_ICmp(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_UnconditionalBr(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::BasicBlock::size(), and llvm::Value::stripPointerCasts().
Referenced by llvm::InstCombiner::visitFree().
|
static |
Try to move the specified instruction from its current block into the beginning of DestBlock, which can only happen if it's safe to move the instruction past all of the instructions between it and the end of its block.
Definition at line 3177 of file InstructionCombining.cpp.
References assert(), llvm::dbgs(), E, llvm::BasicBlock::end(), llvm::findDbgUsers(), llvm::MetadataAsValue::get(), llvm::ValueAsMetadata::get(), llvm::UndefValue::get(), llvm::Value::getContext(), llvm::BasicBlock::getFirstInsertionPt(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::Value::hasOneUse(), llvm::Instruction::isEHPad(), llvm::Instruction::isTerminator(), LLVM_DEBUG, llvm::Instruction::mayHaveSideEffects(), llvm::Instruction::mayReadFromMemory(), llvm::Instruction::moveBefore(), llvm::reverse(), llvm::salvageDebugInfoForDbgValues(), llvm::User::setOperand(), and llvm::RegState::Undef.
Referenced by llvm::InstCombiner::run().
|
static |
Referenced by llvm::InstCombiner::run().
|
static |
Referenced by combineInstructionsOverFunction().
| Combine redundant false |
Definition at line 3731 of file InstructionCombining.cpp.
|
static |
Referenced by combineInstructionsOverFunction().
| instcombine |
Definition at line 3731 of file InstructionCombining.cpp.
|
static |
Definition at line 126 of file InstructionCombining.cpp.
|
static |
Definition at line 125 of file InstructionCombining.cpp.
| Combine redundant instructions |
Definition at line 3731 of file InstructionCombining.cpp.
|
static |
Referenced by combineInstructionsOverFunction().
|
static |
Referenced by combineInstructionsOverFunction().
|
static |
Referenced by combineInstructionsOverFunction().
1.8.13