LLVM  14.0.0git
Classes | Namespaces | Macros | Functions | Variables
InstCombinePHI.cpp File Reference
#include "InstCombineInternal.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Transforms/InstCombine/InstCombiner.h"
#include "llvm/Transforms/Utils/Local.h"
Include dependency graph for InstCombinePHI.cpp:

Go to the source code of this file.

Classes

struct  llvm::DenseMapInfo< LoweredPHIRecord >
 

Namespaces

 llvm
 ---------------------— PointerInfo ------------------------------------—
 

Macros

#define DEBUG_TYPE   "instcombine"
 

Functions

 STATISTIC (NumPHIsOfInsertValues, "Number of phi-of-insertvalue turned into insertvalue-of-phis")
 
 STATISTIC (NumPHIsOfExtractValues, "Number of phi-of-extractvalue turned into extractvalue-of-phi")
 
 STATISTIC (NumPHICSEs, "Number of PHI's that got CSE'd")
 
static bool isSafeAndProfitableToSinkLoad (LoadInst *L)
 Return true if we know that it is safe to sink the load out of the block that defines it. More...
 
static bool DeadPHICycle (PHINode *PN, SmallPtrSetImpl< PHINode * > &PotentiallyDeadPHIs)
 Return true if this PHI node is only used by a PHI node cycle that is dead. More...
 
static bool PHIsEqualValue (PHINode *PN, Value *NonPhiInVal, SmallPtrSetImpl< PHINode * > &ValueEqualPHIs)
 Return true if this phi node is always equal to NonPhiInVal. More...
 
static ConstantIntGetAnyNonZeroConstInt (PHINode &PN)
 Return an existing non-zero constant if this phi node has one, otherwise return constant 1. More...
 
static ValueSimplifyUsingControlFlow (InstCombiner &Self, PHINode &PN, const DominatorTree &DT)
 

Variables

static cl::opt< unsigned > MaxNumPhis ("instcombine-max-num-phis", cl::init(512), cl::desc("Maximum number phis to handle in intptr/ptrint folding"))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "instcombine"

Definition at line 27 of file InstCombinePHI.cpp.

Function Documentation

◆ DeadPHICycle()

static bool DeadPHICycle ( PHINode PN,
SmallPtrSetImpl< PHINode * > &  PotentiallyDeadPHIs 
)
static

Return true if this PHI node is only used by a PHI node cycle that is dead.

Definition at line 958 of file InstCombinePHI.cpp.

References llvm::Value::hasOneUse(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SmallPtrSetImplBase::size(), llvm::Value::use_empty(), and llvm::Instruction::user_back().

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

◆ GetAnyNonZeroConstInt()

static ConstantInt* GetAnyNonZeroConstInt ( PHINode PN)
static

Return an existing non-zero constant if this phi node has one, otherwise return constant 1.

Definition at line 1005 of file InstCombinePHI.cpp.

References assert(), llvm::ConstantInt::get(), llvm::Value::getType(), and llvm::User::operands().

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

◆ isSafeAndProfitableToSinkLoad()

static bool isSafeAndProfitableToSinkLoad ( LoadInst L)
static

Return true if we know that it is safe to sink the load out of the block that defines it.

This means that it must be obvious the value of the load is not changed from the point of the load to the end of the block it is in.

Finally, it is safe, but not profitable, to sink a load targeting a non-address-taken alloca. Doing so will cause us to not promote the alloca to a register.

Definition at line 614 of file InstCombinePHI.cpp.

References E, llvm::BasicBlock::end(), GEP, llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::User::getOperand(), llvm::Instruction::getParent(), SI, and llvm::Value::users().

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

◆ PHIsEqualValue()

static bool PHIsEqualValue ( PHINode PN,
Value NonPhiInVal,
SmallPtrSetImpl< PHINode * > &  ValueEqualPHIs 
)
static

Return true if this phi node is always equal to NonPhiInVal.

This happens with mutually cyclic phi nodes like: z = some value; x = phi (y, z); y = phi (x, z)

Definition at line 980 of file InstCombinePHI.cpp.

References llvm::PHINode::incoming_values(), llvm::SmallPtrSetImpl< PtrType >::insert(), and llvm::SmallPtrSetImplBase::size().

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

◆ SimplifyUsingControlFlow()

static Value* SimplifyUsingControlFlow ( InstCombiner Self,
PHINode PN,
const DominatorTree DT 
)
static

◆ STATISTIC() [1/3]

STATISTIC ( NumPHICSEs  ,
"Number of PHI's that got CSE'd  
)

◆ STATISTIC() [2/3]

STATISTIC ( NumPHIsOfExtractValues  ,
"Number of phi-of-extractvalue turned into extractvalue-of-phi"   
)

◆ STATISTIC() [3/3]

STATISTIC ( NumPHIsOfInsertValues  ,
"Number of phi-of-insertvalue turned into insertvalue-of-phis"   
)

Variable Documentation

◆ MaxNumPhis

cl::opt<unsigned> MaxNumPhis("instcombine-max-num-phis", cl::init(512), cl::desc("Maximum number phis to handle in intptr/ptrint folding"))
static