|
LLVM 23.0.0git
|
#include "InstCombineInternal.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/PatternMatch.h"#include "llvm/Transforms/InstCombine/InstCombiner.h"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 Instruction * | dropRedundantMaskingOfLeftShiftInput (BinaryOperator *OuterShift, const SimplifyQuery &Q, InstCombiner::BuilderTy &Builder) |
| static Instruction * | foldShiftOfShiftedBinOp (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 Value * | foldShiftedShift (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) |
| #define DEBUG_TYPE "instcombine" |
Definition at line 21 of file InstCombineShifts.cpp.
|
static |
Return true if we can simplify two logical (either left or right) shifts that have constant shift amounts: OuterShift (InnerShift X, C1), C2.
Definition at line 575 of file InstCombineShifts.cpp.
References assert(), llvm::cast(), llvm::APInt::getLowBitsSet(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::APInt::getZExtValue(), llvm::Instruction::isLogicalShift(), llvm::Lossy, llvm::PatternMatch::m_APInt(), llvm::InstCombiner::MaskedValueIsZero(), MaskShift(), llvm::PatternMatch::match(), llvm::Signed, llvm::APInt::ugt(), and llvm::APInt::ult().
|
static |
Definition at line 871 of file InstCombineShifts.cpp.
References llvm::BinaryOperator::getOpcode(), llvm::Instruction::isLogicalShift(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().
Referenced by llvm::InstCombinerImpl::FoldShiftByConstant().
| bool canTryToConstantAddTwoShiftAmounts | ( | Value * | Sh0, |
| Value * | ShAmt0, | ||
| Value * | Sh1, | ||
| Value * | ShAmt1 ) |
Definition at line 23 of file InstCombineShifts.cpp.
References llvm::APInt::getAllOnes(), getScalarSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), and llvm::APInt::uge().
Referenced by dropRedundantMaskingOfLeftShiftInput(), and llvm::InstCombinerImpl::reassociateShiftAmtsOfTwoSameDirectionShifts().
|
static |
Definition at line 189 of file InstCombineShifts.cpp.
References assert(), canTryToConstantAddTwoShiftAmounts(), llvm::ConstantFoldBinaryOpOperands(), llvm::ConstantFoldCastOperand(), llvm::BinaryOperator::Create(), llvm::SimplifyQuery::DL, llvm::dyn_cast_or_null(), llvm::Constant::getAllOnesValue(), llvm::Type::getExtendedType(), llvm::ConstantExpr::getNot(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::ConstantInt::getSigned(), llvm::ConstantExpr::getSub(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::Value::hasOneUse(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_c_And(), llvm::PatternMatchHelpers::m_CombineAnd(), llvm::PatternMatchHelpers::m_CombineOr(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_LShr(), llvm::MIPatternMatch::m_Not(), llvm::PatternMatch::m_One(), llvm::PatternMatch::m_Shift(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Shr(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExtOrSelf(), llvm::Masked, llvm::PatternMatch::match(), llvm::IntegerType::MAX_INT_BITS, llvm::Constant::replaceUndefsWith(), llvm::simplifyAddInst(), llvm::simplifySubInst(), and X.
Referenced by llvm::InstCombinerImpl::visitShl().
|
static |
Fold OuterShift (InnerShift X, C1), C2.
See canEvaluateShiftedShift() for the constraints on these instructions.
Definition at line 724 of file InstCombineShifts.cpp.
References assert(), llvm::dyn_cast(), llvm::APInt::getHighBitsSet(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::APInt::getLowBitsSet(), llvm::Constant::getNullValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::APInt::getZExtValue(), llvm::Instruction::hasNoSignedWrap(), llvm::Instruction::hasNoUnsignedWrap(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::match(), llvm::Instruction::setHasNoSignedWrap(), llvm::Instruction::setHasNoUnsignedWrap(), llvm::Instruction::setIsExact(), llvm::User::setOperand(), llvm::Signed, and llvm::Unsigned.
|
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().
|
static |
Definition at line 1092 of file InstCombineShifts.cpp.
References llvm::SimplifyQuery::AC, assert(), llvm::BitWidth, Changed, llvm::computeKnownBits(), llvm::ComputeNumSignBits(), llvm::KnownBits::countMinLeadingZeros(), llvm::KnownBits::countMinSignBits(), llvm::KnownBits::countMinTrailingZeros(), llvm::SimplifyQuery::CxtI, llvm::SimplifyQuery::DL, llvm::SimplifyQuery::DT, llvm::KnownBits::getBitWidth(), llvm::APInt::getLimitedValue(), llvm::KnownBits::getMaxValue(), I, llvm::PatternMatch::m_Intrinsic(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().
Referenced by llvm::InstCombinerImpl::visitAShr(), llvm::InstCombinerImpl::visitLShr(), and llvm::InstCombinerImpl::visitShl().