LLVM API Documentation

Defines | Functions
InstCombineSelect.cpp File Reference
#include "InstCombine.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/IR/PatternMatch.h"
Include dependency graph for InstCombineSelect.cpp:

Go to the source code of this file.

Defines

#define DEBUG_TYPE   "instcombine"

Functions

static SelectPatternFlavor MatchSelectPattern (Value *V, Value *&LHS, Value *&RHS)
static unsigned GetSelectFoldableOperands (Instruction *I)
static ConstantGetSelectFoldableConstant (Instruction *I)
static bool isSelect01 (Constant *C1, Constant *C2)
static ValueSimplifyWithOpReplaced (Value *V, Value *Op, Value *RepOp, const DataLayout *TD, const TargetLibraryInfo *TLI, DominatorTree *DT, AssumptionTracker *AT)
static ValuefoldSelectICmpAndOr (const SelectInst &SI, Value *TrueVal, Value *FalseVal, InstCombiner::BuilderTy *Builder)
static bool CanSelectOperandBeMappingIntoPredBlock (const Value *V, const SelectInst &SI)
static ValuefoldSelectICmpAnd (const SelectInst &SI, ConstantInt *TrueVal, ConstantInt *FalseVal, InstCombiner::BuilderTy *Builder)

Define Documentation

#define DEBUG_TYPE   "instcombine"

Definition at line 21 of file InstCombineSelect.cpp.


Function Documentation

CanSelectOperandBeMappingIntoPredBlock - SI is a select whose condition is a PHI node (but the two may be in different blocks). See if the true/false values (V) are live in all of the predecessor blocks of the PHI. For example, cases like this cannot be mapped:

X = phi [ C1, BB1], [C2, BB2] Y = add Z = select X, Y, 0

because Y is not live in BB1/BB2.

Definition at line 666 of file InstCombineSelect.cpp.

References llvm::dyn_cast(), llvm::SelectInst::getCondition(), llvm::Instruction::getParent(), and I.

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

static Value* foldSelectICmpAnd ( const SelectInst SI,
ConstantInt TrueVal,
ConstantInt FalseVal,
InstCombiner::BuilderTy Builder 
) [static]
static Value* foldSelectICmpAndOr ( const SelectInst SI,
Value TrueVal,
Value FalseVal,
InstCombiner::BuilderTy Builder 
) [static]
static Constant* GetSelectFoldableConstant ( Instruction I) [static]

GetSelectFoldableConstant - For the same transformation as the previous function, return the identity constant that goes into the select.

Definition at line 128 of file InstCombineSelect.cpp.

References llvm::Add, llvm::APIntOps::And(), llvm::ConstantInt::get(), llvm::Constant::getAllOnesValue(), llvm::Constant::getNullValue(), llvm::Instruction::getOpcode(), llvm::Value::getType(), llvm_unreachable, llvm::LShr, llvm::APIntOps::Or(), llvm::Sub, and llvm::APIntOps::Xor().

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

GetSelectFoldableOperands - We want to turn code that looks like this: C = or A, B D = select cond, C, A into: C = select cond, B, 0 D = or A, C

Assuming that the specified instruction is an operand to the select, return a bitmask indicating which operands of this instruction are foldable if they equal the other incoming value of the select.

Definition at line 108 of file InstCombineSelect.cpp.

References llvm::Add, llvm::APIntOps::And(), llvm::Instruction::getOpcode(), llvm::LShr, llvm::APIntOps::Or(), llvm::Sub, and llvm::APIntOps::Xor().

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

static bool isSelect01 ( Constant C1,
Constant C2 
) [static]
static SelectPatternFlavor MatchSelectPattern ( Value V,
Value *&  LHS,
Value *&  RHS 
) [static]
static Value* SimplifyWithOpReplaced ( Value V,
Value Op,
Value RepOp,
const DataLayout TD,
const TargetLibraryInfo TLI,
DominatorTree DT,
AssumptionTracker AT 
) [static]