LLVM
8.0.1
|
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/BlockFrequencyInfo.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/MemoryBuiltins.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/ISDOpcodes.h"
#include "llvm/CodeGen/SelectionDAGNodes.h"
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.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/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InlineAsm.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/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/Statepoint.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/IR/ValueMap.h"
#include "llvm/Pass.h"
#include "llvm/Support/BlockFrequency.h"
#include "llvm/Support/BranchProbability.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MachineValueType.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/BypassSlowDivision.h"
#include "llvm/Transforms/Utils/SimplifyLibCalls.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iterator>
#include <limits>
#include <memory>
#include <utility>
#include <vector>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "codegenprepare" |
Enumerations | |
enum | ExtType |
Functions | |
STATISTIC (NumBlocksElim, "Number of blocks eliminated") | |
STATISTIC (NumPHIsElim, "Number of trivial PHIs eliminated") | |
STATISTIC (NumGEPsElim, "Number of GEPs converted to casts") | |
STATISTIC (NumCmpUses, "Number of uses of Cmp expressions replaced with uses of " "sunken Cmps") | |
STATISTIC (NumCastUses, "Number of uses of Cast expressions replaced with uses " "of sunken Casts") | |
STATISTIC (NumMemoryInsts, "Number of memory instructions whose address " "computations were sunk") | |
STATISTIC (NumMemoryInstsPhiCreated, "Number of phis created when address " "computations were sunk to memory instructions") | |
STATISTIC (NumMemoryInstsSelectCreated, "Number of select created when address " "computations were sunk to memory instructions") | |
STATISTIC (NumExtsMoved, "Number of [s|z]ext instructions combined with loads") | |
STATISTIC (NumExtUses, "Number of uses of [s|z]ext instructions optimized") | |
STATISTIC (NumAndsAdded, "Number of and mask instructions added to form ext loads") | |
STATISTIC (NumAndUses, "Number of uses of and mask instructions optimized") | |
STATISTIC (NumRetsDup, "Number of return instructions duplicated") | |
STATISTIC (NumDbgValueMoved, "Number of debug value instructions moved") | |
STATISTIC (NumSelectsExpanded, "Number of selects turned into branches") | |
STATISTIC (NumStoreExtractExposed, "Number of store(extractelement) exposed") | |
INITIALIZE_PASS_BEGIN (CodeGenPrepare, DEBUG_TYPE, "Optimize for code generation", false, false) INITIALIZE_PASS_END(CodeGenPrepare | |
static void | computeBaseDerivedRelocateMap (const SmallVectorImpl< GCRelocateInst *> &AllRelocateCalls, DenseMap< GCRelocateInst *, SmallVector< GCRelocateInst *, 2 >> &RelocateInstMap) |
static bool | getGEPSmallConstantIntOffsetV (GetElementPtrInst *GEP, SmallVectorImpl< Value *> &OffsetV) |
static bool | simplifyRelocatesOffABase (GCRelocateInst *RelocatedBase, const SmallVectorImpl< GCRelocateInst *> &Targets) |
static bool | SinkCast (CastInst *CI) |
SinkCast - Sink the specified cast instruction into its user blocks. More... | |
static bool | OptimizeNoopCopyExpression (CastInst *CI, const TargetLowering &TLI, const DataLayout &DL) |
If the specified cast instruction is a noop copy (e.g. More... | |
static bool | CombineUAddWithOverflow (CmpInst *CI) |
Try to combine CI into a call to the llvm.uadd.with.overflow intrinsic if possible. More... | |
static bool | SinkCmpExpression (CmpInst *CI, const TargetLowering *TLI) |
Sink the given CmpInst into user blocks to reduce the number of virtual registers that must be created and coalesced. More... | |
static bool | OptimizeCmpExpression (CmpInst *CI, const TargetLowering *TLI) |
static bool | sinkAndCmp0Expression (Instruction *AndI, const TargetLowering &TLI, SetOfInstrs &InsertedInsts) |
Duplicate and sink the given 'and' instruction into user blocks where it is used in a compare to allow isel to generate better code for targets where this operation can be combined. More... | |
static bool | isExtractBitsCandidateUse (Instruction *User) |
Check if the candidates could be combined with a shift instruction, which includes: More... | |
static bool | SinkShiftAndTruncate (BinaryOperator *ShiftI, Instruction *User, ConstantInt *CI, DenseMap< BasicBlock *, BinaryOperator *> &InsertedShifts, const TargetLowering &TLI, const DataLayout &DL) |
Sink both shift and truncate instruction to the use of truncate's BB. More... | |
static bool | OptimizeExtractBits (BinaryOperator *ShiftI, ConstantInt *CI, const TargetLowering &TLI, const DataLayout &DL) |
Sink the shift right instruction into user blocks if the uses could potentially be combined with this shift instruction and generate BitExtract instruction. More... | |
static bool | despeculateCountZeros (IntrinsicInst *CountZeros, const TargetLowering *TLI, const DataLayout *DL, bool &ModifiedDT) |
If counting leading or trailing zeros is an expensive operation and a zero input is defined, add a check for zero to avoid calling the intrinsic. More... | |
static raw_ostream & | operator<< (raw_ostream &OS, const ExtAddrMode &AM) |
static bool | MightBeFoldableInst (Instruction *I) |
This is a little filter, which returns true if an addressing computation involving I might be folded into a load/store accessing it. More... | |
static bool | isPromotedInstructionLegal (const TargetLowering &TLI, const DataLayout &DL, Value *Val) |
Check whether or not Val is a legal instruction for TLI . More... | |
static bool | IsOperandAMemoryOperand (CallInst *CI, InlineAsm *IA, Value *OpVal, const TargetLowering &TLI, const TargetRegisterInfo &TRI) |
Check to see if all uses of OpVal by the specified inline asm call are due to memory operands. More... | |
static bool | FindAllMemoryUses (Instruction *I, SmallVectorImpl< std::pair< Instruction *, unsigned >> &MemoryUses, SmallPtrSetImpl< Instruction *> &ConsideredInsts, const TargetLowering &TLI, const TargetRegisterInfo &TRI, int SeenInsts=0) |
Recursively walk all the uses of I until we find a memory use. More... | |
static bool | IsNonLocalValue (Value *V, BasicBlock *BB) |
Return true if the specified values are defined in a different basic block than BB. More... | |
static bool | hasSameExtUse (Value *Val, const TargetLowering &TLI) |
Check if all the uses of Val are equivalent (or free) zero or sign extensions. More... | |
static bool | sinkSelectOperand (const TargetTransformInfo *TTI, Value *V) |
Check if V (an operand of a select instruction) is an expensive instruction that is only used once. More... | |
static bool | isFormingBranchFromSelectProfitable (const TargetTransformInfo *TTI, const TargetLowering *TLI, SelectInst *SI) |
Returns true if a SelectInst should be turned into an explicit branch. More... | |
static Value * | getTrueOrFalseValue (SelectInst *SI, bool isTrue, const SmallPtrSet< const Instruction *, 2 > &Selects) |
If isTrue is true, return the true value of SI , otherwise return false value of SI . More... | |
static bool | isBroadcastShuffle (ShuffleVectorInst *SVI) |
static bool | splitMergedValStore (StoreInst &SI, const DataLayout &DL, const TargetLowering &TLI) |
For the instruction sequence of store below, F and I values are bundled together as an i64 value before being stored into memory. More... | |
static bool | GEPSequentialConstIndexed (GetElementPtrInst *GEP) |
static bool | tryUnmergingGEPsAcrossIndirectBr (GetElementPtrInst *GEPI, const TargetTransformInfo *TTI) |
static bool | makeBitReverse (Instruction &I, const DataLayout &DL, const TargetLowering &TLI) |
Given an OR instruction, check to see if this is a bitreverse idiom. More... | |
static void | scaleWeights (uint64_t &NewTrue, uint64_t &NewFalse) |
Scale down both weights to fit into uint32_t. More... | |
Variables | |
static cl::opt< bool > | DisableBranchOpts ("disable-cgp-branch-opts", cl::Hidden, cl::init(false), cl::desc("Disable branch optimizations in CodeGenPrepare")) |
static cl::opt< bool > | DisableGCOpts ("disable-cgp-gc-opts", cl::Hidden, cl::init(false), cl::desc("Disable GC optimizations in CodeGenPrepare")) |
static cl::opt< bool > | DisableSelectToBranch ("disable-cgp-select2branch", cl::Hidden, cl::init(false), cl::desc("Disable select to branch conversion.")) |
static cl::opt< bool > | AddrSinkUsingGEPs ("addr-sink-using-gep", cl::Hidden, cl::init(true), cl::desc("Address sinking in CGP using GEPs.")) |
static cl::opt< bool > | EnableAndCmpSinking ("enable-andcmp-sinking", cl::Hidden, cl::init(true), cl::desc("Enable sinkinig and/cmp into branches.")) |
static cl::opt< bool > | DisableStoreExtract ("disable-cgp-store-extract", cl::Hidden, cl::init(false), cl::desc("Disable store(extract) optimizations in CodeGenPrepare")) |
static cl::opt< bool > | StressStoreExtract ("stress-cgp-store-extract", cl::Hidden, cl::init(false), cl::desc("Stress test store(extract) optimizations in CodeGenPrepare")) |
static cl::opt< bool > | DisableExtLdPromotion ("disable-cgp-ext-ld-promotion", cl::Hidden, cl::init(false), cl::desc("Disable ext(promotable(ld)) -> promoted(ext(ld)) optimization in " "CodeGenPrepare")) |
static cl::opt< bool > | StressExtLdPromotion ("stress-cgp-ext-ld-promotion", cl::Hidden, cl::init(false), cl::desc("Stress test ext(promotable(ld)) -> promoted(ext(ld)) " "optimization in CodeGenPrepare")) |
static cl::opt< bool > | DisablePreheaderProtect ("disable-preheader-prot", cl::Hidden, cl::init(false), cl::desc("Disable protection against removing loop preheaders")) |
static cl::opt< bool > | ProfileGuidedSectionPrefix ("profile-guided-section-prefix", cl::Hidden, cl::init(true), cl::ZeroOrMore, cl::desc("Use profile info to add section prefix for hot/cold functions")) |
static cl::opt< unsigned > | FreqRatioToSkipMerge ("cgp-freq-ratio-to-skip-merge", cl::Hidden, cl::init(2), cl::desc("Skip merging empty blocks if (frequency of empty block) / " "(frequency of destination block) is greater than this ratio")) |
static cl::opt< bool > | ForceSplitStore ("force-split-store", cl::Hidden, cl::init(false), cl::desc("Force store splitting no matter what the target query says.")) |
static cl::opt< bool > | EnableTypePromotionMerge ("cgp-type-promotion-merge", cl::Hidden, cl::desc("Enable merging of redundant sexts when one is dominating" " the other."), cl::init(true)) |
static cl::opt< bool > | DisableComplexAddrModes ("disable-complex-addr-modes", cl::Hidden, cl::init(false), cl::desc("Disables combining addressing modes with different parts " "in optimizeMemoryInst.")) |
static cl::opt< bool > | AddrSinkNewPhis ("addr-sink-new-phis", cl::Hidden, cl::init(false), cl::desc("Allow creation of Phis in Address sinking.")) |
static cl::opt< bool > | AddrSinkNewSelects ("addr-sink-new-select", cl::Hidden, cl::init(true), cl::desc("Allow creation of selects in Address sinking.")) |
static cl::opt< bool > | AddrSinkCombineBaseReg ("addr-sink-combine-base-reg", cl::Hidden, cl::init(true), cl::desc("Allow combining of BaseReg field in Address sinking.")) |
static cl::opt< bool > | AddrSinkCombineBaseGV ("addr-sink-combine-base-gv", cl::Hidden, cl::init(true), cl::desc("Allow combining of BaseGV field in Address sinking.")) |
static cl::opt< bool > | AddrSinkCombineBaseOffs ("addr-sink-combine-base-offs", cl::Hidden, cl::init(true), cl::desc("Allow combining of BaseOffs field in Address sinking.")) |
static cl::opt< bool > | AddrSinkCombineScaledReg ("addr-sink-combine-scaled-reg", cl::Hidden, cl::init(true), cl::desc("Allow combining of ScaledReg field in Address sinking.")) |
static cl::opt< bool > | EnableGEPOffsetSplit ("cgp-split-large-offset-gep", cl::Hidden, cl::init(true), cl::desc("Enable splitting large offset of GEP.")) |
DEBUG_TYPE | |
Optimize for code | generation |
Optimize for code | false |
static constexpr int | MaxMemoryUsesToScan = 20 |
#define DEBUG_TYPE "codegenprepare" |
Definition at line 103 of file CodeGenPrepare.cpp.
enum ExtType |
Definition at line 226 of file CodeGenPrepare.cpp.
Try to combine CI into a call to the llvm.uadd.with.overflow intrinsic if possible.
Return true if any changes were made.
Definition at line 1155 of file CodeGenPrepare.cpp.
References assert(), B, llvm::CallInst::Create(), llvm::ExtractValueInst::Create(), llvm::Instruction::eraseFromParent(), llvm::Instruction::getDebugLoc(), llvm::Intrinsic::getDeclaration(), llvm::Instruction::getModule(), llvm::Instruction::getParent(), llvm::Value::getType(), llvm::Value::hasOneUse(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_UAddWithOverflow(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::Value::replaceAllUsesWith(), llvm::Instruction::setDebugLoc(), llvm::Intrinsic::uadd_with_overflow, and llvm::Value::user_begin().
Referenced by OptimizeCmpExpression().
|
static |
Definition at line 851 of file CodeGenPrepare.cpp.
References I, and llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::insert().
Referenced by simplifyRelocatesOffABase().
|
static |
If counting leading or trailing zeros is an expensive operation and a zero input is defined, add a check for zero to avoid calling the intrinsic.
We want to transform: z = call i64 .cttz.i64(i64 A, i1 false)
into: entry: cmpz = icmp eq i64 A, 0 br i1 cmpz, label cond.end, label cond.false cond.false: z = call i64 .cttz.i64(i64 A, i1 true) br label cond.end cond.end: ctz = phi i64 [ 64, entry ], [ z, cond.false ]
If the transform is performed, return true and set ModifiedDT to true.
Definition at line 1562 of file CodeGenPrepare.cpp.
References llvm::Intrinsic::aarch64_stlxr, llvm::Intrinsic::aarch64_stxr, llvm::PHINode::addIncoming(), Arg, llvm::CallBase::arg_operands(), assert(), llvm::attributesPermitTailCall(), llvm::BasicBlock::begin(), llvm::GlobalValue::canIncreaseAlignment(), llvm::Attribute::Cold, llvm::ScaledNumbers::compare(), llvm::countPopulation(), llvm::Intrinsic::ctlz, llvm::Intrinsic::cttz, llvm::dump(), llvm::dyn_cast(), E, llvm::SmallVectorBase::empty(), llvm::Instruction::eraseFromParent(), llvm::BasicBlock::eraseFromParent(), llvm::tgtok::Field, llvm::FoldReturnIntoUncondBranch(), llvm::BasicBlock::front(), llvm::ConstantInt::get(), llvm::AllocaInst::getAlignment(), llvm::AllocaInst::getAllocatedType(), llvm::CallBase::getArgOperand(), llvm::CallBase::getCalledFunction(), llvm::CallBase::getCalledValue(), llvm::Value::getContext(), llvm::Instruction::getDebugLoc(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::IntrinsicInst::getIntrinsicID(), llvm::getKnownAlignment(), llvm::DataLayout::getLargestLegalIntTypeSizeInBits(), llvm::APInt::getLimitedValue(), llvm::Constant::getNullValue(), llvm::PHINode::getNumIncomingValues(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::Type::getPointerAddressSpace(), llvm::Value::getPointerAlignment(), llvm::Type::getPrimitiveSizeInBits(), llvm::ReturnInst::getReturnValue(), llvm::BranchInst::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::GlobalValue::getValueType(), llvm::BasicBlock::hasAddressTaken(), llvm::CallBase::hasFnAttr(), llvm::Value::hasOneUse(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::Intrinsic::is_constant, llvm::TargetLoweringBase::isCheapToSpeculateCtlz(), llvm::TargetLoweringBase::isCheapToSpeculateCttz(), llvm::Type::isPointerTy(), isTrivial(), llvm::BranchInst::isUnconditional(), llvm::Type::isVectorTy(), llvm::Intrinsic::launder_invariant_group, llvm_unreachable, llvm::lowerObjectSizeCall(), llvm::PatternMatch::m_One(), llvm::PatternMatch::match(), MI, llvm::Instruction::moveBefore(), llvm::Intrinsic::objectsize, llvm::FortifiedLibCallSimplifier::optimizeCall(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::pred_begin(), llvm::pred_end(), print(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::replaceAndRecursivelySimplify(), llvm::GlobalObject::setAlignment(), llvm::AllocaInst::setAlignment(), llvm::CallBase::setArgOperand(), llvm::IRBuilderBase::SetInsertPoint(), llvm::SmallVectorBase::size(), llvm::BasicBlock::splitBasicBlock(), llvm::Intrinsic::strip_invariant_group, llvm::Value::stripAndAccumulateInBoundsConstantOffsets(), and llvm::Value::use_empty().
|
static |
Recursively walk all the uses of I until we find a memory use.
If we find an obviously non-foldable instruction, return true. Add the ultimately found memory instructions to MemoryUses.
Definition at line 4258 of file CodeGenPrepare.cpp.
References llvm::Address, assert(), llvm::SmallVectorImpl< T >::clear(), llvm::Attribute::Cold, llvm::dyn_cast(), llvm::PointerType::getAddressSpace(), llvm::CallBase::getCalledValue(), llvm::PointerType::getElementType(), llvm::Instruction::getFunction(), llvm::User::getOperand(), llvm::StoreInst::getPointerOperandIndex(), llvm::AtomicCmpXchgInst::getPointerOperandIndex(), llvm::AtomicRMWInst::getPointerOperandIndex(), llvm::Value::getType(), llvm::CallBase::hasFnAttr(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::is_contained(), IsOperandAMemoryOperand(), llvm::Value::isUsedInBasicBlock(), MightBeFoldableInst(), llvm::Function::optForSize(), SI, llvm::SmallVectorBase::size(), Success, TRI, and llvm::Value::uses().
|
static |
Definition at line 6493 of file CodeGenPrepare.cpp.
References llvm::gep_type_begin(), llvm::User::getNumOperands(), llvm::User::getOperand(), and llvm::generic_gep_type_iterator< ItTy >::isSequential().
Referenced by tryUnmergingGEPsAcrossIndirectBr().
|
static |
Definition at line 886 of file CodeGenPrepare.cpp.
References llvm::dyn_cast(), llvm::User::getNumOperands(), llvm::User::getOperand(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by simplifyRelocatesOffABase().
|
static |
If isTrue
is true, return the true value of SI
, otherwise return false value of SI
.
If the true/false value of SI
is defined by any select instructions in Selects
, look through the defining select instruction until the true/false value is not defined in Selects
.
Definition at line 5715 of file CodeGenPrepare.cpp.
References llvm::PHINode::addIncoming(), assert(), llvm::SmallVectorTemplateCommon< T >::back(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::BasicBlock::Create(), llvm::PHINode::Create(), llvm::BranchInst::Create(), DisableSelectToBranch, llvm::dyn_cast(), llvm::BasicBlock::end(), llvm::Instruction::eraseFromParent(), llvm::BasicBlock::front(), llvm::SelectInst::getCondition(), llvm::Value::getContext(), llvm::Instruction::getDebugLoc(), llvm::SelectInst::getFalseValue(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Instruction::getMetadata(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getTerminator(), llvm::SelectInst::getTrueValue(), llvm::Value::getType(), isFormingBranchFromSelectProfitable(), llvm::Type::isIntegerTy(), llvm::TargetLoweringBase::isSelectSupported(), llvm::Type::isVectorTy(), llvm::LLVMContext::MD_unpredictable, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::TargetLoweringBase::ScalarCondVectorVal, llvm::TargetLoweringBase::ScalarValSelect, llvm::Instruction::setDebugLoc(), SI, sinkSelectOperand(), llvm::BasicBlock::splitBasicBlock(), llvm::Value::takeName(), and llvm::TargetLoweringBase::VectorMaskSelect.
|
static |
Check if all the uses of Val
are equivalent (or free) zero or sign extensions.
Definition at line 4890 of file CodeGenPrepare.cpp.
References assert(), llvm::SmallVectorTemplateCommon< T >::back(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::EVT::bitsGT(), llvm::IRBuilder< T, Inserter >::CreateGEP(), llvm::IRBuilder< T, Inserter >::CreatePointerCast(), DisableExtLdPromotion, llvm::DominatorTree::dominates(), llvm::dyn_cast(), llvm::SmallVectorBase::empty(), llvm::SmallPtrSetImplBase::empty(), llvm::TargetLoweringBase::enableExtLdPromotion(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::SmallVectorImpl< T >::erase(), llvm::Instruction::eraseFromParent(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::SmallVectorTemplateCommon< T >::front(), GEP, llvm::ConstantInt::get(), llvm::APInt::getActiveBits(), llvm::GetElementPtrInst::getAddressSpace(), llvm::Type::getContext(), llvm::Value::getContext(), llvm::Instruction::getDebugLoc(), llvm::Function::getEntryBlock(), llvm::BasicBlock::getFirstInsertionPt(), llvm::Instruction::getFunction(), llvm::Type::getInt8PtrTy(), llvm::Type::getInt8Ty(), llvm::Type::getIntegerBitWidth(), llvm::Type::getIntNTy(), llvm::ConstantInt::getLimitedValue(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), getParent(), llvm::Type::getPointerAddressSpace(), llvm::GetElementPtrInst::getResultElementType(), llvm::Type::getScalarType(), llvm::EVT::getSizeInBits(), llvm::Value::getType(), llvm::TargetLoweringBase::getValueType(), llvm::Value::hasOneUse(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::TargetLoweringBase::isExtFree(), llvm::TargetLoweringBase::isExtLoad(), llvm::Type::isIntOrPtrTy(), llvm::TargetLoweringBase::isLegalAddressingMode(), llvm::TargetLoweringBase::isLoadExtLegal(), llvm::APInt::isMask(), isPromotedInstructionLegal(), llvm::EVT::isRound(), llvm::LoadInst::isSimple(), llvm::TargetLoweringBase::isTruncateFree(), llvm::TargetLoweringBase::isZExtFree(), llvm::SPII::Load, llvm::max(), llvm::Instruction::moveAfter(), llvm::SmallVectorTemplateBase< T >::pop_back(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Instruction::removeFromParent(), llvm::Value::replaceAllUsesWith(), llvm::Instruction::setDebugLoc(), llvm::APInt::setLowBits(), llvm::sort(), llvm::SplitEdge(), StressExtLdPromotion, llvm::APInt::ugt(), llvm::Value::use_empty(), llvm::Value::user_begin(), llvm::Value::users(), llvm::Value::uses(), and llvm::ISD::ZEXTLOAD.
INITIALIZE_PASS_BEGIN | ( | CodeGenPrepare | , |
DEBUG_TYPE | , | ||
"Optimize for code generation" | , | ||
false | , | ||
false | |||
) |
|
static |
Definition at line 5894 of file CodeGenPrepare.cpp.
References llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Align, llvm::TargetLoweringBase::allowsMisalignedMemoryAccesses(), Arg, assert(), llvm::SmallVectorTemplateCommon< T >::back(), llvm::SwitchInst::cases(), Context, llvm::CastInst::Create(), llvm::dbgs(), llvm::SmallVectorBase::empty(), llvm::Instruction::eraseFromParent(), llvm::ConstantInt::get(), llvm::StoreInst::getAlignment(), llvm::TargetTransformInfo::getArithmeticInstrCost(), getBitWidth(), llvm::SwitchInst::getCondition(), getConstantVector(), llvm::Value::getContext(), llvm::Instruction::getDebugLoc(), llvm::Type::getIntNTy(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::StoreInst::getPointerAddressSpace(), llvm::TargetLoweringBase::getRegisterType(), llvm::ShuffleVectorInst::getShuffleMask(), llvm::MVT::getSizeInBits(), llvm::Value::getType(), llvm::ShuffleVectorInst::getType(), llvm::StoreInst::getValueOperand(), llvm::TargetLoweringBase::getValueType(), llvm::TargetTransformInfo::getVectorInstrCost(), llvm::Instruction::isShift(), llvm::TargetLoweringBase::isVectorShiftByScalarCheap(), LLVM_DEBUG, llvm::BitmaskEnumDetail::Mask(), llvm::max(), llvm::TargetTransformInfo::OK_AnyValue, llvm::TargetTransformInfo::OK_UniformConstantValue, llvm::User::replaceUsesOfWith(), llvm::SwitchInst::setCondition(), llvm::APInt::sext(), llvm::ARM_MB::ST, llvm::Value::use_empty(), llvm::Value::users(), and llvm::APInt::zext().
|
static |
Check if the candidates could be combined with a shift instruction, which includes:
Definition at line 1357 of file CodeGenPrepare.cpp.
References llvm::Instruction::getOpcode(), and llvm::User::getOperand().
Referenced by OptimizeExtractBits().
|
static |
Returns true if a SelectInst should be turned into an explicit branch.
Definition at line 5671 of file CodeGenPrepare.cpp.
References llvm::dyn_cast(), llvm::Instruction::extractProfMetadata(), llvm::BranchProbability::getBranchProbability(), llvm::SelectInst::getCondition(), llvm::SelectInst::getFalseValue(), llvm::TargetLoweringBase::getPredictableBranchThreshold(), llvm::SelectInst::getTrueValue(), llvm::Value::hasOneUse(), llvm::TargetLoweringBase::isPredictableSelectExpensive(), llvm::max(), and sinkSelectOperand().
Referenced by getTrueOrFalseValue().
|
static |
Return true if the specified values are defined in a different basic block than BB.
Definition at line 4472 of file CodeGenPrepare.cpp.
References AddrSinkUsingGEPs, assert(), llvm::SmallVectorTemplateCommon< T, typename >::back(), llvm::BasicBlock::begin(), llvm::TargetLowering::C_Memory, llvm::SmallVectorImpl< T >::clear(), llvm::TargetLowering::ComputeConstraintToUse(), llvm::TargetLowering::AsmOperandInfo::ConstraintType, llvm::IRBuilder< T, Inserter >::CreateAdd(), llvm::IRBuilder< T, Inserter >::CreateGEP(), llvm::IRBuilder< T, Inserter >::CreateIntCast(), llvm::IRBuilder< T, Inserter >::CreateIntToPtr(), llvm::IRBuilder< T, Inserter >::CreateMul(), llvm::IRBuilder< T, Inserter >::CreatePointerCast(), llvm::IRBuilder< T, Inserter >::CreatePtrToInt(), llvm::IRBuilder< T, Inserter >::CreateTrunc(), llvm::dbgs(), llvm::SmallVectorBase::empty(), llvm::Instruction::eraseFromParent(), GEP, llvm::ConstantInt::get(), llvm::CallBase::getArgOperand(), getBitWidth(), llvm::Instruction::getFunction(), llvm::IRBuilderBase::getInt8PtrTy(), llvm::IRBuilderBase::getInt8Ty(), llvm::Constant::getNullValue(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::Type::getPointerAddressSpace(), llvm::GetElementPtrInst::getPointerOperand(), llvm::Value::getType(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::InlineAsm::ConstraintInfo::isIndirect, llvm::InlineAsm::isInput, llvm::Type::isPointerTy(), LLVM_DEBUG, llvm::Match, llvm::none_of(), P, llvm::TargetLowering::ParseConstraints(), llvm::WeakTrackingVH::pointsToAliveValue(), llvm::SmallVectorTemplateBase< T, bool >::pop_back(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::RecursivelyDeleteTriviallyDeadInstructions(), llvm::User::replaceUsesOfWith(), SI, llvm::SystemZISD::TM, TRI, llvm::InlineAsm::ConstraintInfo::Type, and llvm::Value::use_empty().
|
static |
Check to see if all uses of OpVal by the specified inline asm call are due to memory operands.
If so, return true, otherwise return false.
Definition at line 4226 of file CodeGenPrepare.cpp.
References llvm::TargetLowering::C_Memory, llvm::TargetLowering::AsmOperandInfo::CallOperandVal, llvm::TargetLowering::ComputeConstraintToUse(), llvm::TargetLowering::AsmOperandInfo::ConstraintType, llvm::Module::getDataLayout(), llvm::Instruction::getFunction(), llvm::GlobalValue::getParent(), llvm::InlineAsm::ConstraintInfo::isIndirect, llvm::TargetLowering::ParseConstraints(), and TRI.
Referenced by FindAllMemoryUses().
|
static |
Check whether or not Val
is a legal instruction for TLI
.
Val
is assumed to be the product of some type promotion. Therefore if Val
has an undefined state in TLI
, this is assumed to be legal, as the non-promoted value would have had the same state. Definition at line 3408 of file CodeGenPrepare.cpp.
References llvm::MCID::Add, assert(), llvm::dbgs(), llvm::Depth, llvm::dyn_cast(), EnableGEPOffsetSplit, llvm::MipsISD::Ext, GEP, llvm::gep_type_begin(), llvm::ConstantInt::get(), llvm::UndefValue::get(), llvm::ConstantInt::getBitWidth(), llvm::StructLayout::getElementOffset(), llvm::Function::getEntryBlock(), llvm::Function::getFunction(), llvm::generic_gep_type_iterator< ItTy >::getIndexedType(), llvm::Type::getIntegerBitWidth(), llvm::MVT::getIntegerVT(), llvm::APInt::getMinSignedBits(), llvm::User::getNumOperands(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::BasicBlock::getParent(), llvm::Type::getPointerAddressSpace(), llvm::ConstantInt::getSExtValue(), llvm::APInt::getSExtValue(), llvm::generic_gep_type_iterator< ItTy >::getStructTypeOrNull(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::TargetLoweringBase::getValueType(), llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), llvm::Value::hasOneUse(), llvm::TargetLoweringBase::InstructionOpcodeToISD(), llvm::APInt::isAllOnesValue(), llvm::Instruction::isEHPad(), llvm::TargetLoweringBase::isExtFree(), llvm::Type::isIntegerTy(), llvm::APInt::isIntN(), llvm::Type::isIntOrPtrTy(), llvm::TargetLoweringBase::isLegalAddressingMode(), llvm::TargetLoweringBase::isNoopAddrSpaceCast(), llvm::TargetLoweringBase::isOperationLegalOrCustom(), llvm::TargetLoweringBase::isTruncateFree(), llvm::Type::isVectorTy(), LLVM_DEBUG, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::TargetLoweringBase::shouldConsiderGEPOffsetSplit(), llvm::Value::use_empty(), and llvm::Value::user_begin().
Referenced by hasSameExtUse().
|
static |
Given an OR instruction, check to see if this is a bitreverse idiom.
If so, insert the new intrinsic and return true.
Definition at line 6795 of file CodeGenPrepare.cpp.
References llvm::SmallVectorTemplateCommon< T >::back(), llvm::BasicBlock::begin(), llvm::ISD::BITREVERSE, llvm::dbgs(), llvm::dyn_cast(), llvm::BasicBlock::end(), llvm::BasicBlock::getFirstInsertionPt(), llvm::Instruction::getParent(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::DbgValueInst::getValue(), llvm::TargetLoweringBase::getValueType(), llvm::Instruction::insertAfter(), llvm::Instruction::insertBefore(), llvm::Instruction::isEHPad(), llvm::Type::isIntegerTy(), llvm::TargetLoweringBase::isOperationLegalOrCustom(), llvm::Instruction::isTerminator(), LLVM_DEBUG, llvm::recognizeBSwapOrBitReverseIdiom(), llvm::RecursivelyDeleteTriviallyDeadInstructions(), llvm::Instruction::removeFromParent(), llvm::Value::replaceAllUsesWith(), llvm::reverse(), and VI.
|
static |
This is a little filter, which returns true if an addressing computation involving I might be folded into a load/store accessing it.
This doesn't need to be perfect, but needs to accept at least the set of instructions that MatchOperationAddr can.
Definition at line 3377 of file CodeGenPrepare.cpp.
References llvm::MCID::Add, llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), and llvm::Type::isIntOrPtrTy().
Referenced by FindAllMemoryUses().
|
inlinestatic |
Definition at line 2049 of file CodeGenPrepare.cpp.
References assert(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::BasicBlock::begin(), llvm::IRBuilder< T, Inserter >::CreateSExt(), llvm::IRBuilder< T, Inserter >::CreateTrunc(), llvm::IRBuilder< T, Inserter >::CreateZExt(), llvm::dbgs(), llvm::Depth, dump(), llvm::SmallVectorTemplateCommon< T >::end(), eraseInstruction(), llvm::findDbgValues(), llvm::MetadataAsValue::get(), llvm::ValueAsMetadata::get(), llvm::UndefValue::get(), llvm::Type::getContext(), llvm::Module::getDataLayout(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Instruction::getModule(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::Value::getType(), llvm::Instruction::insertAfter(), llvm::Instruction::insertBefore(), LLVM_DEBUG, LLVM_DUMP_METHOD, llvm::Match, MI, llvm::Instruction::moveBefore(), llvm::Value::mutateType(), print(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Instruction::removeFromParent(), llvm::Value::replaceAllUsesWith(), llvm::SmallVectorImpl< T >::reserve(), llvm::User::setOperand(), llvm::SmallVectorBase::size(), Success, TRI, and llvm::Value::uses().
|
static |
Definition at line 1265 of file CodeGenPrepare.cpp.
References CombineUAddWithOverflow(), and SinkCmpExpression().
Referenced by tryUnmergingGEPsAcrossIndirectBr().
|
static |
Sink the shift right instruction into user blocks if the uses could potentially be combined with this shift instruction and generate BitExtract instruction.
It will only be applied if the architecture supports BitExtract instruction. Here is an example: BB1: x.extract.shift = lshr i64 arg1, 32 BB2: x.extract.trunc = trunc i64 x.extract.shift to i16 ==>
BB2: x.extract.shift.1 = lshr i64 arg1, 32 x.extract.trunc = trunc i64 x.extract.shift.1 to i16
CodeGen will recognize the pattern in BB2 and generate BitExtract instruction. Return true if any changes are made.
Only insert instructions in each block once.
Definition at line 1462 of file CodeGenPrepare.cpp.
References assert(), E, llvm::BasicBlock::end(), llvm::Instruction::eraseFromParent(), llvm::Instruction::getDebugLoc(), llvm::BasicBlock::getFirstInsertionPt(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::Value::getType(), llvm::TargetLoweringBase::getValueType(), isExtractBitsCandidateUse(), llvm::TargetLoweringBase::isTypeLegal(), llvm::salvageDebugInfo(), llvm::Instruction::setDebugLoc(), SinkShiftAndTruncate(), llvm::Value::use_empty(), llvm::Value::user_begin(), and llvm::Value::user_end().
Referenced by tryUnmergingGEPsAcrossIndirectBr().
|
static |
If the specified cast instruction is a noop copy (e.g.
it's casting from one pointer type to another, i32->i8 on PPC), sink it into user blocks to reduce the number of virtual registers that must be created and coalesced.
Return true if any changes are made.
Definition at line 1112 of file CodeGenPrepare.cpp.
References llvm::EVT::bitsLT(), llvm::Value::getContext(), llvm::User::getOperand(), llvm::Value::getType(), llvm::TargetLoweringBase::getTypeAction(), llvm::TargetLoweringBase::getTypeToTransformTo(), llvm::TargetLoweringBase::getValueType(), llvm::TargetLoweringBase::isCheapAddrSpaceCast(), llvm::EVT::isInteger(), SinkCast(), and llvm::TargetLoweringBase::TypePromoteInteger.
Referenced by tryUnmergingGEPsAcrossIndirectBr().
|
static |
Scale down both weights to fit into uint32_t.
Definition at line 6883 of file CodeGenPrepare.cpp.
References llvm::BasicBlock::Create(), llvm::dbgs(), llvm::Value::dump(), llvm::Instruction::eraseFromParent(), llvm::BasicBlock::getContext(), llvm::Value::getName(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::BasicBlock::getParent(), llvm::BasicBlock::getTerminator(), llvm::Instruction::insertBefore(), llvm::TargetLoweringBase::isJumpExpensive(), LLVM_DEBUG, llvm::PatternMatch::m_And(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_Br(), llvm::PatternMatch::m_Cmp(), llvm::PatternMatch::m_CombineOr(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::max(), llvm::LLVMContext::MD_prof, llvm::LLVMContext::MD_unpredictable, llvm::BasicBlock::phis(), llvm::Instruction::removeFromParent(), std::swap(), and llvm::SystemZISD::TM.
|
static |
Definition at line 903 of file CodeGenPrepare.cpp.
References assert(), computeBaseDerivedRelocateMap(), llvm::dyn_cast(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::empty(), llvm::GCRelocateInst::getBasePtrIndex(), llvm::BasicBlock::getFirstInsertionPt(), getGEPSmallConstantIntOffsetV(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::GCProjectionInst::getStatepoint(), llvm::Value::getType(), I, llvm::makeArrayRef(), llvm::Instruction::moveBefore(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::IRBuilderBase::SetCurrentDebugLocation(), llvm::SmallVectorBase::size(), llvm::Value::takeName(), and llvm::Value::users().
|
static |
Duplicate and sink the given 'and' instruction into user blocks where it is used in a compare to allow isel to generate better code for targets where this operation can be combined.
Return true if any changes are made.
Definition at line 1280 of file CodeGenPrepare.cpp.
References assert(), llvm::BinaryOperator::Create(), llvm::dbgs(), llvm::Value::dump(), llvm::dyn_cast(), E, llvm::Instruction::eraseFromParent(), llvm::Instruction::getDebugLoc(), llvm::User::getOperand(), llvm::Instruction::getParent(), getParent(), llvm::Value::hasOneUse(), llvm::TargetLoweringBase::isMaskAndCmp0FoldingBeneficial(), LLVM_DEBUG, llvm::Instruction::setDebugLoc(), llvm::Value::user_begin(), llvm::Value::user_end(), and llvm::Value::users().
Referenced by tryUnmergingGEPsAcrossIndirectBr().
SinkCast - Sink the specified cast instruction into its user blocks.
InsertedCasts - Only insert a cast in each block once.
Definition at line 1044 of file CodeGenPrepare.cpp.
References assert(), llvm::CastInst::Create(), E, llvm::BasicBlock::end(), llvm::Instruction::eraseFromParent(), llvm::Instruction::getDebugLoc(), llvm::BasicBlock::getFirstInsertionPt(), llvm::CastInst::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::Instruction::isEHPad(), llvm::salvageDebugInfo(), llvm::Instruction::setDebugLoc(), llvm::Value::use_empty(), llvm::Value::user_begin(), and llvm::Value::user_end().
Referenced by OptimizeNoopCopyExpression(), and tryUnmergingGEPsAcrossIndirectBr().
|
static |
Sink the given CmpInst into user blocks to reduce the number of virtual registers that must be created and coalesced.
This is a clear win except on targets with multiple condition code registers (PowerPC), where it might lose; some adjustment may be wanted there.
Return true if any changes are made.
Definition at line 1208 of file CodeGenPrepare.cpp.
References assert(), llvm::CmpInst::Create(), E, llvm::BasicBlock::end(), llvm::Instruction::eraseFromParent(), llvm::Instruction::getDebugLoc(), llvm::BasicBlock::getFirstInsertionPt(), llvm::CmpInst::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::CmpInst::getPredicate(), llvm::Instruction::setDebugLoc(), llvm::Value::use_empty(), llvm::Value::user_begin(), llvm::Value::user_end(), and llvm::TargetLoweringBase::useSoftFloat().
Referenced by OptimizeCmpExpression().
|
static |
Check if V (an operand of a select instruction) is an expensive instruction that is only used once.
Definition at line 5662 of file CodeGenPrepare.cpp.
References llvm::dyn_cast(), llvm::TargetTransformInfo::getUserCost(), llvm::Value::hasOneUse(), llvm::isSafeToSpeculativelyExecute(), and llvm::TargetTransformInfo::TCC_Expensive.
Referenced by getTrueOrFalseValue(), and isFormingBranchFromSelectProfitable().
|
static |
Sink both shift and truncate instruction to the use of truncate's BB.
Definition at line 1373 of file CodeGenPrepare.cpp.
References assert(), llvm::CastInst::Create(), llvm::dyn_cast(), llvm::BasicBlock::end(), llvm::Instruction::getDebugLoc(), llvm::BasicBlock::getFirstInsertionPt(), llvm::Instruction::getOpcode(), llvm::BinaryOperator::getOpcode(), llvm::CastInst::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::Value::getType(), llvm::TargetLoweringBase::getValueType(), llvm::TargetLoweringBase::InstructionOpcodeToISD(), llvm::TargetLoweringBase::isOperationLegalOrCustom(), llvm::Instruction::setDebugLoc(), llvm::Value::user_begin(), and llvm::Value::user_end().
Referenced by OptimizeExtractBits().
|
static |
For the instruction sequence of store below, F and I values are bundled together as an i64 value before being stored into memory.
Sometimes it is more efficient to generate separate stores for F and I, which can remove the bitwise instructions or sink them to colder places.
(store (or (zext (bitcast F to i32) to i64), (shl (zext I to i64), 32)), addr) –> (store F, addr) and (store I, addr+4)
Similarly, splitting for other merged store can also be beneficial, like: For pair of {i32, i32}, i64 store –> two i32 stores. For pair of {i32, i16}, i64 store –> two i32 stores. For pair of {i16, i16}, i32 store –> two i16 stores. For pair of {i16, i8}, i32 store –> two i16 stores. For pair of {i8, i8}, i16 store –> two i8 stores.
We allow each target to determine specifically which kind of splitting is supported.
The store patterns are commonly seen from the simple code snippet below if only std::make_pair(...) is sroa transformed before inlined into hoo. void goo(const std::pair<int, float> &); hoo() { ... goo(std::make_pair(tmp, ftmp)); ... }
Although we already have similar splitting in DAG Combine, we duplicate it in CodeGenPrepare to catch the case in which pattern is across multiple BBs. The logic in DAG Combine is kept to catch case generated during code expansion.
Definition at line 6411 of file CodeGenPrepare.cpp.
References llvm::dyn_cast(), llvm::Instruction::eraseFromParent(), ForceSplitStore, llvm::ConstantInt::get(), llvm::StoreInst::getAlignment(), llvm::Value::getContext(), llvm::Module::getDataLayout(), llvm::EVT::getEVT(), llvm::Type::getInt32Ty(), llvm::Type::getIntNTy(), llvm::Instruction::getModule(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::StoreInst::getPointerAddressSpace(), llvm::Type::getPointerTo(), llvm::Value::getType(), llvm::DataLayout::getTypeSizeInBits(), llvm::DataLayout::getTypeStoreSizeInBits(), llvm::StoreInst::getValueOperand(), llvm::Type::isIntegerTy(), llvm::DataLayout::isLittleEndian(), llvm::TargetLoweringBase::isMultiStoresCheaperThanBitsMerge(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_SpecificInt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::IRBuilderBase::SetInsertPoint(), and llvm::Upper.
Referenced by ShrinkLoadReplaceStoreWithStore(), and tryUnmergingGEPsAcrossIndirectBr().
STATISTIC | ( | NumBlocksElim | , |
"Number of blocks eliminated" | |||
) |
STATISTIC | ( | NumPHIsElim | , |
"Number of trivial PHIs eliminated" | |||
) |
STATISTIC | ( | NumGEPsElim | , |
"Number of GEPs converted to casts" | |||
) |
STATISTIC | ( | NumCmpUses | , |
"Number of uses of Cmp expressions replaced with uses of " "sunken Cmps" | |||
) |
STATISTIC | ( | NumCastUses | , |
"Number of uses of Cast expressions replaced with uses " "of sunken Casts" | |||
) |
STATISTIC | ( | NumMemoryInsts | , |
"Number of memory instructions whose address " "computations were sunk" | |||
) |
STATISTIC | ( | NumMemoryInstsPhiCreated | , |
"Number of phis created when address " "computations were sunk to memory instructions" | |||
) |
STATISTIC | ( | NumMemoryInstsSelectCreated | , |
"Number of select created when address " "computations were sunk to memory instructions" | |||
) |
STATISTIC | ( | NumExtsMoved | , |
"Number of ext instructions combined with loads" | [s|z] | ||
) |
STATISTIC | ( | NumExtUses | , |
"Number of uses of ext instructions optimized" | [s|z] | ||
) |
STATISTIC | ( | NumAndsAdded | , |
"Number of and mask instructions added to form ext loads" | |||
) |
STATISTIC | ( | NumAndUses | , |
"Number of uses of and mask instructions optimized" | |||
) |
STATISTIC | ( | NumRetsDup | , |
"Number of return instructions duplicated" | |||
) |
STATISTIC | ( | NumDbgValueMoved | , |
"Number of debug value instructions moved" | |||
) |
STATISTIC | ( | NumSelectsExpanded | , |
"Number of selects turned into branches" | |||
) |
STATISTIC | ( | NumStoreExtractExposed | , |
"Number of store(extractelement) exposed" | |||
) |
|
static |
Definition at line 6557 of file CodeGenPrepare.cpp.
References assert(), llvm::dyn_cast(), EnableAndCmpSinking, llvm::find_if(), GEPSequentialConstIndexed(), llvm::ConstantInt::get(), llvm::Value::getContext(), llvm::TargetTransformInfo::getIntImmCost(), llvm::User::getOperand(), llvm::Instruction::getParent(), getParent(), llvm::LoadInst::getPointerAddressSpace(), llvm::BasicBlock::getTerminator(), getType(), llvm::ConstantInt::getType(), llvm::Value::getType(), llvm::TargetLoweringBase::getTypeAction(), llvm::ConstantInt::getValue(), llvm::TargetLoweringBase::getValueType(), llvm::TargetLoweringBase::hasExtractBitsInsn(), llvm::TargetLoweringBase::hasMultipleConditionRegisters(), I, llvm::GetElementPtrInst::isInBounds(), llvm::LLVMContext::MD_invariant_group, Modified, NC, OptimizeCmpExpression(), OptimizeExtractBits(), OptimizeNoopCopyExpression(), P, llvm::Instruction::setDebugLoc(), llvm::Instruction::setMetadata(), llvm::User::setOperand(), llvm::SimplifyInstruction(), sinkAndCmp0Expression(), SinkCast(), splitMergedValStore(), llvm::TargetTransformInfo::TCC_Basic, llvm::TargetLoweringBase::TypeExpandInteger, and llvm::Value::users().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Referenced by IsNonLocalValue().
DEBUG_TYPE |
Definition at line 388 of file CodeGenPrepare.cpp.
|
static |
Referenced by llvm::createCodeGenPreparePass().
|
static |
|
static |
Referenced by hasSameExtUse().
|
static |
Referenced by llvm::createCodeGenPreparePass().
|
static |
Referenced by llvm::createCodeGenPreparePass().
|
static |
Referenced by getTrueOrFalseValue().
|
static |
|
static |
Referenced by tryUnmergingGEPsAcrossIndirectBr().
|
static |
Referenced by isPromotedInstructionLegal().
|
static |
Referenced by llvm::createCodeGenPreparePass().
Optimize for code false |
Definition at line 388 of file CodeGenPrepare.cpp.
|
static |
Referenced by splitMergedValStore().
|
static |
Referenced by llvm::createCodeGenPreparePass().
Optimize for code generation |
Definition at line 388 of file CodeGenPrepare.cpp.
|
static |
Definition at line 4253 of file CodeGenPrepare.cpp.
|
static |
Referenced by llvm::createCodeGenPreparePass().
|
static |
Referenced by hasSameExtUse().