|
LLVM
10.0.0
|
#include "InstCombineInternal.h"#include "llvm/Analysis/ConstantFolding.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/PatternMatch.h"Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "instcombine" |
Functions | |
| static Instruction * | dropRedundantMaskingOfLeftShiftInput (BinaryOperator *OuterShift, const SimplifyQuery &Q, InstCombiner::BuilderTy &Builder) |
| static Instruction * | foldShiftOfShiftedLogic (BinaryOperator &I, InstCombiner::BuilderTy &Builder) |
| If we have a shift-by-constant of a bitwise logic op 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. More... | |
| 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 Value * | foldShiftedShift (BinaryOperator *InnerShift, unsigned OuterShAmt, bool IsOuterShl, InstCombiner::BuilderTy &Builder) |
| Fold OuterShift (InnerShift X, C1), C2. More... | |
| static Value * | getShiftedValue (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... | |
| static bool | canShiftBinOpWithConstantRHS (BinaryOperator &Shift, BinaryOperator *BO) |
| #define DEBUG_TYPE "instcombine" |
Definition at line 21 of file InstCombineShifts.cpp.
|
static |
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 475 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::getValue(), 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().
|
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 423 of file InstCombineShifts.cpp.
References assert(), llvm::APInt::getLowBitsSet(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::Instruction::isLogicalShift(), llvm::PatternMatch::m_APInt(), llvm::BitmaskEnumDetail::Mask(), llvm::InstCombiner::MaskedValueIsZero(), and llvm::PatternMatch::match().
Referenced by canEvaluateShifted().
|
static |
Definition at line 668 of file InstCombineShifts.cpp.
References llvm::MCID::Add, and llvm::BinaryOperator::getOpcode().
Referenced by llvm::InstCombiner::FoldShiftByConstant().
|
static |
Definition at line 178 of file InstCombineShifts.cpp.
References assert(), llvm::BinaryOperator::Create(), llvm::IRBuilder< T, Inserter >::CreateTrunc(), llvm::ConstantInt::get(), llvm::Constant::getAllOnesValue(), llvm::Type::getExtendedType(), llvm::ConstantExpr::getLShr(), llvm::ConstantExpr::getNot(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::ConstantExpr::getShl(), llvm::ConstantExpr::getSub(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::ConstantExpr::getZExt(), llvm::Value::hasOneUse(), llvm::IRBuilder< T, Inserter >::Insert(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_AShr(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_CombineAnd(), llvm::PatternMatch::m_CombineOr(), llvm::PatternMatch::m_Deferred(), 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_Xor(), llvm::PatternMatch::m_ZExtOrSelf(), llvm::PatternMatch::match(), llvm::Constant::replaceUndefsWith(), llvm::SimplifyAddInst(), llvm::SimplifySubInst(), and X.
Referenced by llvm::InstCombiner::visitShl().
|
static |
Fold OuterShift (InnerShift X, C1), C2.
See canEvaluateShiftedShift() for the constraints on these instructions.
Definition at line 548 of file InstCombineShifts.cpp.
References assert(), llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::ConstantInt::get(), llvm::APInt::getHighBitsSet(), llvm::APInt::getLowBitsSet(), llvm::Constant::getNullValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::APInt::getZExtValue(), llvm::PatternMatch::m_APInt(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), llvm::Instruction::setHasNoSignedWrap(), llvm::Instruction::setHasNoUnsignedWrap(), llvm::Instruction::setIsExact(), llvm::User::setOperand(), and llvm::Value::takeName().
Referenced by getShiftedValue().
|
static |
If we have a shift-by-constant of a bitwise logic op 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 a use of an intermediate value (reduces dependency chain).
Definition at line 323 of file InstCombineShifts.cpp.
References assert(), llvm::BinaryOperator::Create(), llvm::IRBuilder< T, Inserter >::CreateBinOp(), llvm::dyn_cast(), llvm::ConstantInt::get(), getOpcode(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::Instruction::isShift(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Shift(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), X, and Y.
Referenced by llvm::InstCombiner::commonShiftTransforms().
|
static |
When canEvaluateShifted() returns true for an expression, this function inserts the new computation that produces the shifted value.
Definition at line 611 of file InstCombineShifts.cpp.
References llvm::InstCombineWorklist::Add(), llvm::InstCombiner::Builder, C, llvm::ConstantFoldConstant(), llvm::IRBuilder< T, Inserter >::CreateLShr(), llvm::IRBuilder< T, Inserter >::CreateShl(), llvm::numbers::e, foldShiftedShift(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getNumIncomingValues(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::InstCombiner::getTargetLibraryInfo(), I, llvm_unreachable, llvm::MCID::Select, llvm::PHINode::setIncomingValue(), llvm::User::setOperand(), and llvm::InstCombiner::Worklist.
Referenced by llvm::InstCombiner::FoldShiftByConstant().
1.8.13