LLVM  6.0.0svn
Classes | Namespaces | Macros | Functions
InstCombinePHI.cpp File Reference
#include "InstCombineInternal.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/PatternMatch.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
 Compute iterated dominance frontiers using a linear time algorithm.
 

Macros

#define DEBUG_TYPE   "instcombine"
 

Functions

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...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "instcombine"

Definition at line 24 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 823 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::InstCombiner::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 870 of file InstCombinePHI.cpp.

References assert(), llvm::ConstantInt::get(), llvm::Type::getPrimitiveSizeInBits(), llvm::Value::getType(), llvm::User::operands(), and llvm::operator<().

Referenced by llvm::InstCombiner::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 486 of file InstCombinePHI.cpp.

References llvm::PHINode::addIncoming(), C, llvm::combineMetadata(), llvm::Instruction::copyIRFlags(), llvm::BinaryOperator::Create(), llvm::CastInst::Create(), llvm::CmpInst::Create(), llvm::PHINode::Create(), llvm::CastInst::CreateZExtOrBitCast(), llvm::dyn_cast(), E, llvm::BasicBlock::end(), GEP, llvm::LoadInst::getAlignment(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Instruction::getMetadata(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), llvm::TerminatorInst::getNumSuccessors(), llvm::CmpInst::getOpcode(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::LoadInst::getPointerAddressSpace(), llvm::CmpInst::getPredicate(), llvm::BasicBlock::getTerminator(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::ConstantExpr::getZExt(), llvm::Value::hasOneUse(), I, llvm::PHINode::incoming_values(), llvm::Instruction::isAtomic(), llvm::Type::isIntegerTy(), llvm::Instruction::isSameOperationAs(), llvm::LoadInst::isVolatile(), isVolatile(), llvm::LLVMContext::MD_alias_scope, llvm::LLVMContext::MD_align, llvm::LLVMContext::MD_dereferenceable, llvm::LLVMContext::MD_dereferenceable_or_null, llvm::LLVMContext::MD_invariant_load, llvm::LLVMContext::MD_noalias, llvm::LLVMContext::MD_nonnull, llvm::LLVMContext::MD_range, llvm::LLVMContext::MD_tbaa, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::Instruction::setMetadata(), llvm::User::setOperand(), SI, and llvm::Value::users().

◆ 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 845 of file InstCombinePHI.cpp.

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

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