LLVM 17.0.0git
Classes | Macros | Functions | Variables
InstructionCombining.cpp File Reference
#include "InstCombineInternal.h"
#include "llvm-c/Initialization.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.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/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/TargetTransformInfo.h"
#include "llvm/Analysis/Utils/Local.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Analysis/VectorUtils.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/DebugInfo.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/EHPersonalities.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/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/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Local.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include "llvm/Transforms/Utils/InstructionWorklist.h"

Go to the source code of this file.

Classes

class  AliasScopeTracker
 

Macros

#define DEBUG_TYPE   "instcombine"
 

Functions

 STATISTIC (NumWorklistIterations, "Number of instruction combining iterations performed")
 
 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.
 
static bool simplifyAssocCastAssoc (BinaryOperator *BinOp1, InstCombinerImpl &IC)
 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))
 
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)".
 
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)".
 
static ValuegetIdentityValue (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).
 
static Instruction::BinaryOps getBinOpsForFactorization (Instruction::BinaryOps TopOpcode, BinaryOperator *Op, Value *&LHS, Value *&RHS)
 This function predicates factorization using distributive laws.
 
static ValuetryFactorization (BinaryOperator &I, const SimplifyQuery &SQ, InstCombiner::BuilderTy &Builder, Instruction::BinaryOps InnerOpcode, Value *A, Value *B, Value *C, Value *D)
 This tries to simplify binary operations by factorizing out common terms (e.
 
static ConstantconstantFoldOperationIntoSelectOperand (Instruction &I, SelectInst *SI, Value *SO)
 
static ValuefoldOperationIntoSelectOperand (Instruction &I, SelectInst *SI, Value *NewOp, InstCombiner &IC)
 
static TypefindElementAtOffset (PointerType *PtrTy, int64_t IntOffset, SmallVectorImpl< Value * > &NewIndices, const DataLayout &DL)
 Given a pointer type and a constant offset, determine whether or not there is a sequence of GEP indices into the pointed type that will land us at the specified offset.
 
static bool shouldMergeGEPs (GEPOperator &GEP, GEPOperator &Src)
 
static bool isMergedGEPInBounds (GEPOperator &GEP1, GEPOperator &GEP2)
 
static InstructionfoldSelectGEP (GetElementPtrInst &GEP, InstCombiner::BuilderTy &Builder)
 Thread a GEP operation with constant indices through the constant true/false arms of a select.
 
static bool isNeverEqualToUnescapedAlloc (Value *V, const TargetLibraryInfo &TLI, Instruction *AI)
 
static bool isRemovableWrite (CallBase &CB, Value *UsedV, const TargetLibraryInfo &TLI)
 Given a call CB which uses an address UsedV, return true if we can prove the call's only possible effect is storing to V.
 
static bool isAllocSiteRemovable (Instruction *AI, SmallVectorImpl< WeakTrackingVH > &Users, const TargetLibraryInfo &TLI)
 
static InstructiontryToMoveFreeBeforeNullTest (CallInst &FI, const DataLayout &DL)
 Move the call to free before a NULL test.
 
static bool isMustTailCall (Value *V)
 
static bool isCatchAll (EHPersonality Personality, Constant *TypeInfo)
 Return 'true' if the given typeinfo will match anything.
 
static bool shorter_filter (const Value *LHS, const Value *RHS)
 
static bool isUsedWithinShuffleVector (Value *V)
 
static bool SoleWriteToDeadLocal (Instruction *I, TargetLibraryInfo &TLI)
 Check for case where the call writes to an otherwise dead alloca.
 
static bool TryToSinkInstruction (Instruction *I, BasicBlock *DestBlock, TargetLibraryInfo &TLI)
 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.
 
static bool prepareICWorklistFromFunction (Function &F, const DataLayout &DL, const TargetLibraryInfo *TLI, InstructionWorklist &ICWorklist)
 Populate the IC worklist from a function, by walking it in depth-first order and adding all reachable code to the worklist.
 
static bool combineInstructionsOverFunction (Function &F, InstructionWorklist &Worklist, AliasAnalysis *AA, AssumptionCache &AC, TargetLibraryInfo &TLI, TargetTransformInfo &TTI, DominatorTree &DT, OptimizationRemarkEmitter &ORE, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI, unsigned MaxIterations, LoopInfo *LI)
 
 INITIALIZE_PASS_BEGIN (InstructionCombiningPass, "instcombine", "Combine redundant instructions", false, false) INITIALIZE_PASS_END(InstructionCombiningPass
 
void LLVMInitializeInstCombine (LLVMPassRegistryRef R)
 

Variables

static constexpr unsigned InstCombineDefaultInfiniteLoopThreshold = 100
 
static cl::opt< boolEnableCodeSinking ("instcombine-code-sinking", cl::desc("Enable code sinking"), cl::init(true))
 
static cl::opt< unsignedMaxSinkNumUsers ("instcombine-max-sink-users", cl::init(32), cl::desc("Maximum number of undroppable users for instruction sinking"))
 
static cl::opt< unsignedInfiniteLoopDetectionThreshold ("instcombine-infinite-loop-threshold", cl::desc("Number of instruction combining iterations considered an " "infinite loop"), cl::init(InstCombineDefaultInfiniteLoopThreshold), cl::Hidden)
 
static cl::opt< unsignedMaxArraySize ("instcombine-maxarray-size", cl::init(1024), cl::desc("Maximum array size considered when doing a combine"))
 
static cl::opt< unsignedShouldLowerDbgDeclare ("instcombine-lower-dbg-declare", cl::Hidden, cl::init(true))
 
 instcombine
 
Combine redundant instructions
 
Combine redundant false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "instcombine"

Definition at line 110 of file InstructionCombining.cpp.

Function Documentation

◆ ClearSubclassDataAfterReassociation()

static void ClearSubclassDataAfterReassociation ( BinaryOperator I)
static

Conservatively clears subclassOptionalData after a reassociation or commutation.

We preserve fast-math flags when applicable as they can be preserved.

Definition at line 307 of file InstructionCombining.cpp.

References I.

Referenced by llvm::InstCombinerImpl::SimplifyAssociativeOrCommutative().

◆ combineInstructionsOverFunction()

static bool combineInstructionsOverFunction ( Function F,
InstructionWorklist Worklist,
AliasAnalysis AA,
AssumptionCache AC,
TargetLibraryInfo TLI,
TargetTransformInfo TTI,
DominatorTree DT,
OptimizationRemarkEmitter ORE,
BlockFrequencyInfo BFI,
ProfileSummaryInfo PSI,
unsigned  MaxIterations,
LoopInfo LI 
)
static

◆ constantFoldOperationIntoSelectOperand()

static Constant * constantFoldOperationIntoSelectOperand ( Instruction I,
SelectInst SI,
Value SO 
)
static

◆ DEBUG_COUNTER()

DEBUG_COUNTER ( VisitCounter  ,
"instcombine-visit"  ,
"Controls which instructions are visited"   
)

◆ findElementAtOffset()

static Type * findElementAtOffset ( PointerType PtrTy,
int64_t  IntOffset,
SmallVectorImpl< Value * > &  NewIndices,
const DataLayout DL 
)
static

Given a pointer type and a constant offset, determine whether or not there is a sequence of GEP indices into the pointed type that will land us at the specified offset.

If so, fill them into NewIndices and return the resultant element type, otherwise return null.

Definition at line 1347 of file InstructionCombining.cpp.

References DL, llvm::ConstantInt::get(), llvm::Type::isSized(), llvm::Offset, and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by llvm::InstCombinerImpl::visitGEPOfBitcast().

◆ foldOperationIntoSelectOperand()

static Value * foldOperationIntoSelectOperand ( Instruction I,
SelectInst SI,
Value NewOp,
InstCombiner IC 
)
static

◆ foldSelectGEP()

static Instruction * foldSelectGEP ( GetElementPtrInst GEP,
InstCombiner::BuilderTy Builder 
)
static

◆ getBinOpsForFactorization()

static Instruction::BinaryOps getBinOpsForFactorization ( Instruction::BinaryOps  TopOpcode,
BinaryOperator Op,
Value *&  LHS,
Value *&  RHS 
)
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 612 of file InstructionCombining.cpp.

References assert(), llvm::CallingConv::C, llvm::ConstantInt::get(), llvm::ConstantExpr::getShl(), LHS, llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and RHS.

Referenced by llvm::InstCombinerImpl::tryFactorizationFolds().

◆ getIdentityValue()

static Value * getIdentityValue ( Instruction::BinaryOps  Opcode,
Value V 
)
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 599 of file InstructionCombining.cpp.

References llvm::ConstantExpr::getBinOpIdentity().

Referenced by llvm::InstCombinerImpl::tryFactorizationFolds().

◆ hasNoSignedWrap()

static bool hasNoSignedWrap ( BinaryOperator I)
static

◆ hasNoUnsignedWrap()

static bool hasNoUnsignedWrap ( BinaryOperator I)
static

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( InstructionCombiningPass  ,
"instcombine"  ,
"Combine redundant instructions"  ,
false  ,
false   
)

◆ isAllocSiteRemovable()

static bool isAllocSiteRemovable ( Instruction AI,
SmallVectorImpl< WeakTrackingVH > &  Users,
const TargetLibraryInfo TLI 
)
static

◆ isCatchAll()

static bool isCatchAll ( EHPersonality  Personality,
Constant TypeInfo 
)
static

◆ isMergedGEPInBounds()

static bool isMergedGEPInBounds ( GEPOperator GEP1,
GEPOperator GEP2 
)
static

◆ isMustTailCall()

static bool isMustTailCall ( Value V)
static

◆ isNeverEqualToUnescapedAlloc()

static bool isNeverEqualToUnescapedAlloc ( Value V,
const TargetLibraryInfo TLI,
Instruction AI 
)
static

Definition at line 2679 of file InstructionCombining.cpp.

References llvm::isAllocLikeFn().

Referenced by isAllocSiteRemovable().

◆ isRemovableWrite()

static bool isRemovableWrite ( CallBase CB,
Value UsedV,
const TargetLibraryInfo TLI 
)
static

Given a call CB which uses an address UsedV, return true if we can prove the call's only possible effect is storing to V.

Definition at line 2691 of file InstructionCombining.cpp.

References llvm::CallBase::doesNotThrow(), llvm::MemoryLocation::getForDest(), llvm::Instruction::isTerminator(), llvm::Value::use_empty(), and llvm::Instruction::willReturn().

Referenced by isAllocSiteRemovable().

◆ isUsedWithinShuffleVector()

static bool isUsedWithinShuffleVector ( Value V)
static

◆ leftDistributesOverRight()

static bool leftDistributesOverRight ( Instruction::BinaryOps  LOp,
Instruction::BinaryOps  ROp 
)
static

Return whether "X LOp (Y ROp Z)" is always equal to "(X LOp Y) ROp (X LOp Z)".

Definition at line 563 of file InstructionCombining.cpp.

Referenced by llvm::InstCombinerImpl::foldUsingDistributiveLaws(), rightDistributesOverLeft(), and tryFactorization().

◆ maintainNoSignedWrap()

static bool maintainNoSignedWrap ( BinaryOperator I,
Value B,
Value C 
)
static

◆ prepareICWorklistFromFunction()

static bool prepareICWorklistFromFunction ( Function F,
const DataLayout DL,
const TargetLibraryInfo TLI,
InstructionWorklist ICWorklist 
)
static

Populate the IC worklist from a function, by walking it in depth-first order and 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 4424 of file InstructionCombining.cpp.

References AliasScopeTracker::analyse(), llvm::append_range(), llvm::CallingConv::C, Cond, llvm::ConstantFoldConstant(), llvm::ConstantFoldInstruction(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dbgs(), DL, llvm::SmallVectorBase< Size_T >::empty(), F, llvm::BasicBlock::getTerminator(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isInstructionTriviallyDead(), AliasScopeTracker::isNoAliasScopeDeclDead(), LLVM_DEBUG, llvm::make_early_inc_range(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::InstructionWorklist::push(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::removeAllNonTerminatorAndEHPadInstructions(), llvm::InstructionWorklist::reserve(), llvm::reverse(), llvm::salvageDebugInfo(), SI, llvm::SmallVectorBase< Size_T >::size(), and llvm::successors().

Referenced by combineInstructionsOverFunction().

◆ rightDistributesOverLeft()

static bool rightDistributesOverLeft ( Instruction::BinaryOps  LOp,
Instruction::BinaryOps  ROp 
)
static

Return whether "(X LOp Y) ROp Z" is always equal to "(X ROp Z) LOp (Y ROp Z)".

Definition at line 584 of file InstructionCombining.cpp.

References llvm::Instruction::isBitwiseLogicOp(), llvm::Instruction::isCommutative(), llvm::Instruction::isShift(), and leftDistributesOverRight().

Referenced by llvm::InstCombinerImpl::foldUsingDistributiveLaws(), and tryFactorization().

◆ shorter_filter()

static bool shorter_filter ( const Value LHS,
const Value RHS 
)
static

Definition at line 3453 of file InstructionCombining.cpp.

References llvm::Value::getType(), LHS, and RHS.

Referenced by llvm::InstCombinerImpl::visitLandingPadInst().

◆ shouldMergeGEPs()

static bool shouldMergeGEPs ( GEPOperator GEP,
GEPOperator Src 
)
static

Definition at line 1365 of file InstructionCombining.cpp.

References GEP.

Referenced by llvm::InstCombinerImpl::visitGEPOfGEP().

◆ simplifyAssocCastAssoc()

static bool simplifyAssocCastAssoc ( BinaryOperator BinOp1,
InstCombinerImpl IC 
)
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 323 of file InstructionCombining.cpp.

References llvm::ConstantExpr::get(), llvm::ConstantExpr::getCast(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), llvm::Instruction::isBitwiseLogicOp(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::match(), and llvm::InstCombiner::replaceOperand().

Referenced by llvm::InstCombinerImpl::SimplifyAssociativeOrCommutative().

◆ SoleWriteToDeadLocal()

static bool SoleWriteToDeadLocal ( Instruction I,
TargetLibraryInfo TLI 
)
static

Check for case where the call writes to an otherwise dead alloca.

This shows up for unused out-params in idiomatic C/C++ code. Note that this helper only analyzes the write; doesn't check any other legality aspect.

Definition at line 4019 of file InstructionCombining.cpp.

References llvm::SmallVectorBase< Size_T >::empty(), llvm::MemoryLocation::getForDest(), llvm::getUnderlyingObject(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SmallVectorImpl< T >::pop_back_val(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by TryToSinkInstruction().

◆ STATISTIC() [1/8]

STATISTIC ( NumCombined  ,
"Number of insts combined"   
)

◆ STATISTIC() [2/8]

STATISTIC ( NumConstProp  ,
"Number of constant folds"   
)

◆ STATISTIC() [3/8]

STATISTIC ( NumDeadInst  ,
"Number of dead inst eliminated"   
)

◆ STATISTIC() [4/8]

STATISTIC ( NumExpand  ,
"Number of expansions"   
)

◆ STATISTIC() [5/8]

STATISTIC ( NumFactor  ,
"Number of factorizations"   
)

◆ STATISTIC() [6/8]

STATISTIC ( NumReassoc  ,
"Number of reassociations"   
)

◆ STATISTIC() [7/8]

STATISTIC ( NumSunkInst  ,
"Number of instructions sunk"   
)

◆ STATISTIC() [8/8]

STATISTIC ( NumWorklistIterations  ,
"Number of instruction combining iterations performed"   
)

◆ tryFactorization()

static Value * tryFactorization ( BinaryOperator I,
const SimplifyQuery SQ,
InstCombiner::BuilderTy Builder,
Instruction::BinaryOps  InnerOpcode,
Value A,
Value B,
Value C,
Value D 
)
static

◆ tryToMoveFreeBeforeNullTest()

static Instruction * tryToMoveFreeBeforeNullTest ( CallInst FI,
const DataLayout DL 
)
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.:

  1. it has only one predecessor P, and P has two successors
  2. it contains the call, noops, and an unconditional branch
  3. its successor is the same as its predecessor's successor

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 2934 of file InstructionCombining.cpp.

References assert(), DL, llvm::CallBase::getArgOperand(), llvm::CallBase::getAttributes(), llvm::Value::getContext(), llvm::Attribute::getDereferenceableBytes(), llvm::Instruction::getParent(), llvm::BasicBlock::getSinglePredecessor(), llvm::BasicBlock::getTerminator(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::BasicBlock::instructionsWithoutDebug(), llvm::Attribute::isValid(), 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::make_early_inc_range(), llvm::PatternMatch::match(), llvm::CallBase::setAttributes(), and llvm::BasicBlock::size().

Referenced by llvm::InstCombinerImpl::visitFree().

◆ TryToSinkInstruction()

static bool TryToSinkInstruction ( Instruction I,
BasicBlock DestBlock,
TargetLibraryInfo TLI 
)
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.

FIXME: We could remove droppable uses that are not dominated by the new position.

Definition at line 4064 of file InstructionCombining.cpp.

References A, B, llvm::dbgs(), E, llvm::findDbgUsers(), llvm::BasicBlock::getFirstInsertionPt(), llvm::BasicBlock::getTerminator(), llvm::BasicBlock::getUniquePredecessor(), I, llvm::SmallSet< T, N, C >::insert(), LLVM_DEBUG, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::reverse(), llvm::salvageDebugInfoForDbgValues(), SoleWriteToDeadLocal(), and llvm::sort().

Referenced by llvm::InstCombinerImpl::run().

Variable Documentation

◆ EnableCodeSinking

cl::opt< bool > EnableCodeSinking("instcombine-code-sinking", cl::desc("Enable code sinking"), cl::init(true)) ( "instcombine-code-sinking"  ,
cl::desc("Enable code sinking")  ,
cl::init(true  
)
static

◆ false

Combine redundant false

Definition at line 4717 of file InstructionCombining.cpp.

◆ InfiniteLoopDetectionThreshold

cl::opt< unsigned > InfiniteLoopDetectionThreshold("instcombine-infinite-loop-threshold", cl::desc("Number of instruction combining iterations considered an " "infinite loop"), cl::init(InstCombineDefaultInfiniteLoopThreshold), cl::Hidden) ( "instcombine-infinite-loop-threshold"  ,
cl::desc("Number of instruction combining iterations considered an " "infinite loop")  ,
cl::init(InstCombineDefaultInfiniteLoopThreshold ,
cl::Hidden   
)
static

◆ instcombine

instcombine

Definition at line 4716 of file InstructionCombining.cpp.

◆ InstCombineDefaultInfiniteLoopThreshold

constexpr unsigned InstCombineDefaultInfiniteLoopThreshold = 100
staticconstexpr

Definition at line 132 of file InstructionCombining.cpp.

◆ instructions

Combine redundant instructions

Definition at line 4717 of file InstructionCombining.cpp.

◆ MaxArraySize

cl::opt< unsigned > MaxArraySize("instcombine-maxarray-size", cl::init(1024), cl::desc("Maximum array size considered when doing a combine")) ( "instcombine-maxarray-size"  ,
cl::init(1024)  ,
cl::desc("Maximum array size considered when doing a combine")   
)
static

◆ MaxSinkNumUsers

cl::opt< unsigned > MaxSinkNumUsers("instcombine-max-sink-users", cl::init(32), cl::desc("Maximum number of undroppable users for instruction sinking")) ( "instcombine-max-sink-users"  ,
cl::init(32)  ,
cl::desc("Maximum number of undroppable users for instruction sinking")   
)
static

◆ ShouldLowerDbgDeclare

cl::opt< unsigned > ShouldLowerDbgDeclare("instcombine-lower-dbg-declare", cl::Hidden, cl::init(true)) ( "instcombine-lower-dbg-declare"  ,
cl::Hidden  ,
cl::init(true  
)
static