LLVM  6.0.0svn
Macros | Functions
InstCombineShifts.cpp File Reference
#include "InstCombineInternal.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/PatternMatch.h"
Include dependency graph for InstCombineShifts.cpp:

Go to the source code of this file.


#define DEBUG_TYPE   "instcombine"


static bool canEvaluateShiftedShift (unsigned OuterShAmt, bool IsOuterShl, Instruction *InnerShift, InstCombiner &IC, Instruction *CxtI)
 Return true if we can simplify two logical (either left or right) shifts that have constant shift amounts: OuterShift (InnerShift X, C1), C2. More...
static bool canEvaluateShifted (Value *V, unsigned NumBits, bool IsLeftShift, InstCombiner &IC, Instruction *CxtI)
 See if we can compute the specified value, but shifted logically to the left or right by some number of bits. More...
static ValuefoldShiftedShift (BinaryOperator *InnerShift, unsigned OuterShAmt, bool IsOuterShl, InstCombiner::BuilderTy &Builder)
 Fold OuterShift (InnerShift X, C1), C2. More...
static ValuegetShiftedValue (Value *V, unsigned NumBits, bool isLeftShift, InstCombiner &IC, const DataLayout &DL)
 When canEvaluateShifted() returns true for an expression, this function inserts the new computation that produces the shifted value. More...

Macro Definition Documentation


#define DEBUG_TYPE   "instcombine"

Definition at line 22 of file InstCombineShifts.cpp.

Function Documentation

◆ canEvaluateShifted()

static bool canEvaluateShifted ( Value V,
unsigned  NumBits,
bool  IsLeftShift,
InstCombiner IC,
Instruction CxtI 

See if we can compute the specified value, but shifted logically to the left or right by some number of bits.

This should return true if the expression can be computed for the same cost as the current expression tree. This is used to eliminate extraneous shifting from things like: C = shl i128 A, 64 D = shl i128 B, 96 E = or i128 C, D F = lshr i128 E, 64 where the client will ask if E can be computed shifted right by 64-bits. If this succeeds, getShiftedValue() will be called to produce the value.

Definition at line 122 of file InstCombineShifts.cpp.

References canEvaluateShiftedShift(), llvm::dyn_cast(), llvm::SelectInst::getFalseValue(), llvm::APInt::getHighBitsSet(), llvm::ConstantInt::getLimitedValue(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::SelectInst::getTrueValue(), llvm::ConstantInt::getZExtValue(), llvm::Value::hasOneUse(), I, llvm::PHINode::incoming_values(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Value(), llvm::MaskedValueIsZero(), llvm::PatternMatch::match(), llvm::MCID::Select, and SI.

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

◆ canEvaluateShiftedShift()

static bool canEvaluateShiftedShift ( unsigned  OuterShAmt,
bool  IsOuterShl,
Instruction InnerShift,
InstCombiner IC,
Instruction CxtI 

◆ foldShiftedShift()

static Value* foldShiftedShift ( BinaryOperator InnerShift,
unsigned  OuterShAmt,
bool  IsOuterShl,
InstCombiner::BuilderTy Builder 

◆ getShiftedValue()

static Value* getShiftedValue ( Value V,
unsigned  NumBits,
bool  isLeftShift,
InstCombiner IC,
const DataLayout DL