LLVM 23.0.0git
InstCombineShifts.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "instcombine"

Functions

bool canTryToConstantAddTwoShiftAmounts (Value *Sh0, Value *ShAmt0, Value *Sh1, Value *ShAmt1)
static InstructiondropRedundantMaskingOfLeftShiftInput (BinaryOperator *OuterShift, const SimplifyQuery &Q, InstCombiner::BuilderTy &Builder)
static InstructionfoldShiftOfShiftedBinOp (BinaryOperator &I, InstCombiner::BuilderTy &Builder)
 If we have a shift-by-constant of a bin op (bitwise logic op or add/sub w/ shl) that itself has a shift-by-constant operand with identical opcode, we may be able to convert that into 2 independent shifts followed by the logic op.
static bool canEvaluateShiftedShift (unsigned OuterShAmt, bool IsOuterShl, ShiftSemantics Semantics, Instruction *InnerShift, InstCombinerImpl &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.
static ValuefoldShiftedShift (BinaryOperator *InnerShift, unsigned OuterShAmt, bool IsOuterShl, ShiftSemantics Semantics, InstCombiner::BuilderTy &Builder)
 Fold OuterShift (InnerShift X, C1), C2.
static bool canShiftBinOpWithConstantRHS (BinaryOperator &Shift, BinaryOperator *BO)
static bool setShiftFlags (BinaryOperator &I, const SimplifyQuery &Q)

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "instcombine"

Definition at line 21 of file InstCombineShifts.cpp.

Function Documentation

◆ canEvaluateShiftedShift()

bool canEvaluateShiftedShift ( unsigned OuterShAmt,
bool IsOuterShl,
ShiftSemantics Semantics,
Instruction * InnerShift,
InstCombinerImpl & IC,
Instruction * CxtI )
static

◆ canShiftBinOpWithConstantRHS()

◆ canTryToConstantAddTwoShiftAmounts()

◆ dropRedundantMaskingOfLeftShiftInput()

◆ foldShiftedShift()

◆ foldShiftOfShiftedBinOp()

Instruction * foldShiftOfShiftedBinOp ( BinaryOperator & I,
InstCombiner::BuilderTy & Builder )
static

If we have a shift-by-constant of a bin op (bitwise logic op or add/sub w/ shl) that itself has a shift-by-constant operand with identical opcode, we may be able to convert that into 2 independent shifts followed by the logic op.

This eliminates a use of an intermediate value (reduces dependency chain).

Definition at line 353 of file InstCombineShifts.cpp.

References assert(), llvm::BinaryOperator::Create(), llvm::dyn_cast(), llvm::ConstantExpr::getAdd(), I, llvm::CmpInst::ICMP_ULT, llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_ImmConstant(), llvm::PatternMatch::m_SpecificInt_ICMP(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), Size, X, and Y.

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

◆ setShiftFlags()