|
LLVM
7.0.0
|
#include "InstCombineInternal.h"#include "llvm/Analysis/CmpInstAnalysis.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/Transforms/Utils/Local.h"#include "llvm/IR/ConstantRange.h"#include "llvm/IR/Intrinsics.h"#include "llvm/IR/PatternMatch.h"Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "instcombine" |
Enumerations | |
| enum | MaskedICmpType { AMask_AllOnes = 1, AMask_NotAllOnes = 2, BMask_AllOnes = 4, BMask_NotAllOnes = 8, Mask_AllZeros = 16, Mask_NotAllZeros = 32, AMask_Mixed = 64, AMask_NotMixed = 128, BMask_Mixed = 256, BMask_NotMixed = 512 } |
| Classify (icmp eq (A & B), C) and (icmp ne (A & B), C) as matching patterns that can be simplified. More... | |
Functions | |
| static unsigned | getFCmpCode (FCmpInst::Predicate CC) |
| Similar to getICmpCode but for FCmpInst. More... | |
| static Value * | getNewICmpValue (bool Sign, unsigned Code, Value *LHS, Value *RHS, InstCombiner::BuilderTy &Builder) |
| This is the complement of getICmpCode, which turns an opcode and two operands into either a constant true or false, or a brand new ICmp instruction. More... | |
| static Value * | getFCmpValue (unsigned Code, Value *LHS, Value *RHS, InstCombiner::BuilderTy &Builder) |
| This is the complement of getFCmpCode, which turns an opcode and two operands into either a FCmp instruction, or a true/false constant. More... | |
| static Value * | SimplifyBSwap (BinaryOperator &I, InstCombiner::BuilderTy &Builder) |
| Transform BITWISE_OP(BSWAP(A),BSWAP(B)) or BITWISE_OP(BSWAP(A), Constant) to BSWAP(BITWISE_OP(A, B)) More... | |
| static unsigned | getMaskedICmpType (Value *A, Value *B, Value *C, ICmpInst::Predicate Pred) |
| Return the set of patterns (from MaskedICmpType) that (icmp SCC (A & B), C) satisfies. More... | |
| static unsigned | conjugateICmpMask (unsigned Mask) |
| Convert an analysis of a masked ICmp into its equivalent if all boolean operations had the opposite sense. More... | |
| static bool | decomposeBitTestICmp (Value *LHS, Value *RHS, CmpInst::Predicate &Pred, Value *&X, Value *&Y, Value *&Z) |
| static Optional< std::pair< unsigned, unsigned > > | getMaskedTypeForICmpPair (Value *&A, Value *&B, Value *&C, Value *&D, Value *&E, ICmpInst *LHS, ICmpInst *RHS, ICmpInst::Predicate &PredL, ICmpInst::Predicate &PredR) |
| Handle (icmp(A & B) ==/!= C) &/| (icmp(A & D) ==/!= E). More... | |
| static Value * | foldLogOpOfMaskedICmps_NotAllZeros_BMask_Mixed (ICmpInst *LHS, ICmpInst *RHS, bool IsAnd, Value *A, Value *B, Value *C, Value *D, Value *E, ICmpInst::Predicate PredL, ICmpInst::Predicate PredR, llvm::InstCombiner::BuilderTy &Builder) |
| Try to fold (icmp(A & B) ==/!= C) &/| (icmp(A & D) ==/!= E) into a single (icmp(A & X) ==/!= Y), where the left-hand side is of type Mask_NotAllZeros and the right hand side is of type BMask_Mixed. More... | |
| static Value * | foldLogOpOfMaskedICmpsAsymmetric (ICmpInst *LHS, ICmpInst *RHS, bool IsAnd, Value *A, Value *B, Value *C, Value *D, Value *E, ICmpInst::Predicate PredL, ICmpInst::Predicate PredR, unsigned LHSMask, unsigned RHSMask, llvm::InstCombiner::BuilderTy &Builder) |
| Try to fold (icmp(A & B) ==/!= 0) &/| (icmp(A & D) ==/!= E) into a single (icmp(A & X) ==/!= Y), where the left-hand side and the right hand side aren't of the common mask pattern type. More... | |
| static Value * | foldLogOpOfMaskedICmps (ICmpInst *LHS, ICmpInst *RHS, bool IsAnd, llvm::InstCombiner::BuilderTy &Builder) |
| Try to fold (icmp(A & B) ==/!= C) &/| (icmp(A & D) ==/!= E) into a single (icmp(A & X) ==/!= Y). More... | |
| static Value * | foldAndOrOfEqualityCmpsWithConstants (ICmpInst *LHS, ICmpInst *RHS, bool JoinedByAnd, InstCombiner::BuilderTy &Builder) |
| static Instruction * | matchDeMorgansLaws (BinaryOperator &I, InstCombiner::BuilderTy &Builder) |
| Match De Morgan's Laws: (~A & ~B) == (~(A | B)) (~A | ~B) == (~(A & B)) More... | |
| static Instruction * | foldLogicCastConstant (BinaryOperator &Logic, CastInst *Cast, InstCombiner::BuilderTy &Builder) |
| Fold {and,or,xor} (cast X), C. More... | |
| static Instruction * | foldAndToXor (BinaryOperator &I, InstCombiner::BuilderTy &Builder) |
| static Instruction * | foldOrToXor (BinaryOperator &I, InstCombiner::BuilderTy &Builder) |
| static bool | canNarrowShiftAmt (Constant *C, unsigned BitWidth) |
| Return true if a constant shift amount is always less than the specified bit-width. More... | |
| static bool | areInverseVectorBitmasks (Constant *C1, Constant *C2) |
| If all elements of two constant vectors are 0/-1 and inverses, return true. More... | |
| static Value * | getSelectCondition (Value *A, Value *B, InstCombiner::BuilderTy &Builder) |
| We have an expression of the form (A & C) | (B & D). More... | |
| static Value * | matchSelectFromAndOr (Value *A, Value *C, Value *B, Value *D, InstCombiner::BuilderTy &Builder) |
| We have an expression of the form (A & C) | (B & D). More... | |
| static Instruction * | foldXorToXor (BinaryOperator &I, InstCombiner::BuilderTy &Builder) |
| A ^ B can be specified using other logic ops in a variety of patterns. More... | |
| static Instruction * | visitMaskedMerge (BinaryOperator &I, InstCombiner::BuilderTy &Builder) |
| If we have a masked merge, in the canonical form of: (assuming that A only has one use.) | A | |B| ((x ^ y) & M) ^ y | D |. More... | |
| #define DEBUG_TYPE "instcombine" |
Definition at line 24 of file InstCombineAndOrXor.cpp.
| enum MaskedICmpType |
Classify (icmp eq (A & B), C) and (icmp ne (A & B), C) as matching patterns that can be simplified.
One of A and B is considered the mask. The other is the value. This is described as the "AMask" or "BMask" part of the enum. If the enum contains only "Mask", then both A and B can be considered masks. If A is the mask, then it was proven that (A & C) == C. This is trivial if C == A or C == 0. If both A and C are constants, this proof is also easy. For the following explanations, we assume that A is the mask.
"AllOnes" declares that the comparison is true only if (A & B) == A or all bits of A are set in B. Example: (icmp eq (A & 3), 3) -> AMask_AllOnes
"AllZeros" declares that the comparison is true only if (A & B) == 0 or all bits of A are cleared in B. Example: (icmp eq (A & 3), 0) -> Mask_AllZeroes
"Mixed" declares that (A & B) == C and C might or might not contain any number of one bits and zero bits. Example: (icmp eq (A & 3), 1) -> AMask_Mixed
"Not" means that in above descriptions "==" should be replaced by "!=". Example: (icmp ne (A & 3), 3) -> AMask_NotAllOnes
If the mask A contains a single bit, then the following is equivalent: (icmp eq (A & B), A) equals (icmp ne (A & B), 0) (icmp ne (A & B), A) equals (icmp eq (A & B), 0)
| Enumerator | |
|---|---|
| AMask_AllOnes | |
| AMask_NotAllOnes | |
| BMask_AllOnes | |
| BMask_NotAllOnes | |
| Mask_AllZeros | |
| Mask_NotAllZeros | |
| AMask_Mixed | |
| AMask_NotMixed | |
| BMask_Mixed | |
| BMask_NotMixed | |
Definition at line 218 of file InstCombineAndOrXor.cpp.
If all elements of two constant vectors are 0/-1 and inverses, return true.
Definition at line 1688 of file InstCombineAndOrXor.cpp.
References llvm::Constant::getAggregateElement(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_Zero(), and llvm::PatternMatch::match().
Referenced by getSelectCondition().
Return true if a constant shift amount is always less than the specified bit-width.
If not, the shift could create poison in the narrower type.
Definition at line 1335 of file InstCombineAndOrXor.cpp.
References C, llvm::dyn_cast(), llvm::Constant::getAggregateElement(), llvm::User::getOperand(), llvm::Type::getScalarSizeInBits(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::Type::getVectorNumElements(), llvm::Type::isVectorTy(), llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_LShr(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Shl(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Sub(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), and X.
Convert an analysis of a masked ICmp into its equivalent if all boolean operations had the opposite sense.
Since each "NotXXX" flag (recording !=) is adjacent to the corresponding normal flag (recording ==), this just involves swapping those bits over.
Definition at line 282 of file InstCombineAndOrXor.cpp.
References AMask_AllOnes, AMask_Mixed, AMask_NotAllOnes, AMask_NotMixed, BMask_AllOnes, BMask_Mixed, BMask_NotAllOnes, BMask_NotMixed, Mask_AllZeros, and Mask_NotAllZeros.
Referenced by foldLogOpOfMaskedICmps(), and foldLogOpOfMaskedICmpsAsymmetric().
|
static |
Definition at line 296 of file InstCombineAndOrXor.cpp.
References llvm::decomposeBitTestICmp(), llvm::ConstantInt::get(), llvm::Value::getType(), and llvm::BitmaskEnumDetail::Mask().
|
static |
Definition at line 807 of file InstCombineAndOrXor.cpp.
References llvm::MCID::Add, llvm::AddOne(), assert(), B, C, llvm::IRBuilder< T, Inserter >::CreateAdd(), llvm::IRBuilder< T, Inserter >::CreateICmp(), llvm::IRBuilder< T, Inserter >::CreateOr(), D, llvm::dyn_cast(), llvm::CmpInst::FCMP_ORD, llvm::CmpInst::FCMP_UNO, foldLogOpOfMaskedICmps(), llvm::ConstantInt::get(), llvm::IntegerType::getBitWidth(), llvm::Type::getContext(), getFCmpCode(), getFCmpValue(), llvm::getICmpCode(), llvm::APInt::getLowBitsSet(), getNewICmpValue(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::CmpInst::getSwappedPredicate(), llvm::ConstantInt::getType(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::ICmpInst::isEquality(), llvm::isKnownToBeAPowerOfTwo(), llvm::APInt::isNullValue(), llvm::APInt::isPowerOf2(), llvm::CmpInst::isSigned(), llvm::ConstantInt::isZero(), llvm_unreachable, llvm::PatternMatch::m_And(), llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_PosZeroFP(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Trunc(), llvm::PatternMatch::m_Value(), llvm::BitmaskEnumDetail::Mask(), llvm::PatternMatch::match(), N, llvm::PredicatesFoldable(), llvm::APInt::sgt(), llvm::SubOne(), std::swap(), llvm::ICmpInst::swapOperands(), llvm::APInt::ugt(), X, and llvm::APInt::zext().
Referenced by matchSelectFromAndOr().
|
static |
Definition at line 1281 of file InstCombineAndOrXor.cpp.
References assert(), B, llvm::BinaryOperator::CreateNot(), llvm::IRBuilder< T, Inserter >::CreateXor(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Value::hasOneUse(), llvm::PatternMatch::m_BinOp(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().
Referenced by llvm::InstCombiner::visitAnd().
|
static |
Fold {and,or,xor} (cast X), C.
Definition at line 1176 of file InstCombineAndOrXor.cpp.
References assert(), C, llvm::CastInst::Create(), llvm::IRBuilder< T, Inserter >::CreateBinOp(), llvm::dyn_cast(), llvm::Value::getName(), llvm::BinaryOperator::getOpcode(), llvm::CastInst::getOpcode(), llvm::User::getOperand(), llvm::ConstantExpr::getSExt(), llvm::CastInst::getSrcTy(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::ConstantExpr::getZExt(), I, llvm::Instruction::isBitwiseLogicOp(), llvm::Type::isIntOrIntVectorTy(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExt(), llvm::PatternMatch::match(), llvm::MipsISD::Ret, and X.
|
static |
Try to fold (icmp(A & B) ==/!= C) &/| (icmp(A & D) ==/!= E) into a single (icmp(A & X) ==/!= Y).
Definition at line 609 of file InstCombineAndOrXor.cpp.
References AMask_AllOnes, AMask_NotAllOnes, assert(), B, BMask_AllOnes, BMask_Mixed, BMask_NotAllOnes, C, conjugateICmpMask(), llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::IRBuilder< T, Inserter >::CreateICmp(), llvm::IRBuilder< T, Inserter >::CreateOr(), D, llvm::dyn_cast(), E, foldLogOpOfMaskedICmpsAsymmetric(), llvm::ConstantInt::get(), getMaskedTypeForICmpPair(), llvm::Constant::getNullValue(), llvm::ConstantExpr::getOr(), llvm::CmpInst::getPredicate(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::ConstantExpr::getXor(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::ICmpInst::isEquality(), llvm::BitmaskEnumDetail::Mask(), Mask_AllZeros, and Mask_NotAllZeros.
Referenced by foldAndOrOfEqualityCmpsWithConstants(), and matchSelectFromAndOr().
|
static |
Try to fold (icmp(A & B) ==/!= C) &/| (icmp(A & D) ==/!= E) into a single (icmp(A & X) ==/!= Y), where the left-hand side is of type Mask_NotAllZeros and the right hand side is of type BMask_Mixed.
For example, (icmp (A & 12) != 0) & (icmp (A & 15) == 8) -> (icmp (A & 15) == 8).
Definition at line 444 of file InstCombineAndOrXor.cpp.
References assert(), B, C, llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::IRBuilder< T, Inserter >::CreateICmp(), D, llvm::dyn_cast(), E, llvm::ConstantInt::get(), llvm::ConstantInt::getType(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::ConstantExpr::getXor(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, and llvm::ConstantInt::isZero().
Referenced by foldLogOpOfMaskedICmpsAsymmetric().
|
static |
Try to fold (icmp(A & B) ==/!= 0) &/| (icmp(A & D) ==/!= E) into a single (icmp(A & X) ==/!= Y), where the left-hand side and the right hand side aren't of the common mask pattern type.
Definition at line 574 of file InstCombineAndOrXor.cpp.
References assert(), BMask_Mixed, conjugateICmpMask(), foldLogOpOfMaskedICmps_NotAllZeros_BMask_Mixed(), llvm::ICmpInst::isEquality(), and Mask_NotAllZeros.
Referenced by foldLogOpOfMaskedICmps().
|
static |
Definition at line 1307 of file InstCombineAndOrXor.cpp.
References assert(), B, llvm::BinaryOperator::CreateNot(), llvm::IRBuilder< T, Inserter >::CreateXor(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::Value::hasOneUse(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().
Referenced by llvm::InstCombiner::visitOr().
|
static |
A ^ B can be specified using other logic ops in a variety of patterns.
We can fold these early and efficiently by morphing an existing instruction.
Definition at line 2281 of file InstCombineAndOrXor.cpp.
References assert(), B, llvm::BinaryOperator::CreateNot(), llvm::IRBuilder< T, Inserter >::CreateXor(), llvm::Constant::getAllOnesValue(), llvm::getICmpCode(), llvm::CmpInst::getInversePredicate(), getNewICmpValue(), llvm::Constant::getNullValue(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::Value::getType(), llvm::Value::hasOneUse(), I, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::isSigned(), llvm::PatternMatch::m_AllOnes(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_Or(), llvm::PatternMatch::m_c_Xor(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), llvm::PredicatesFoldable(), llvm::User::setOperand(), llvm::CmpInst::setPredicate(), llvm::SimplifyBinOp(), and llvm::ICmpInst::swapOperands().
Referenced by llvm::InstCombiner::visitXor().
|
static |
Similar to getICmpCode but for FCmpInst.
This encodes a fcmp predicate into a four bit mask.
Definition at line 28 of file InstCombineAndOrXor.cpp.
References assert(), llvm::CmpInst::FCMP_FALSE, llvm::CmpInst::FCMP_OEQ, llvm::CmpInst::FCMP_OGE, llvm::CmpInst::FCMP_OGT, llvm::CmpInst::FCMP_OLE, llvm::CmpInst::FCMP_OLT, llvm::CmpInst::FCMP_ONE, llvm::CmpInst::FCMP_ORD, llvm::CmpInst::FCMP_TRUE, llvm::CmpInst::FCMP_UEQ, llvm::CmpInst::FCMP_UGE, llvm::CmpInst::FCMP_UGT, llvm::CmpInst::FCMP_ULE, llvm::CmpInst::FCMP_ULT, llvm::CmpInst::FCMP_UNE, and llvm::CmpInst::FCMP_UNO.
Referenced by foldAndOrOfEqualityCmpsWithConstants().
|
static |
This is the complement of getFCmpCode, which turns an opcode and two operands into either a FCmp instruction, or a true/false constant.
Definition at line 66 of file InstCombineAndOrXor.cpp.
References assert(), llvm::IRBuilder< T, Inserter >::CreateFCmp(), llvm::CmpInst::FCMP_FALSE, llvm::CmpInst::FCMP_TRUE, llvm::ConstantInt::get(), llvm::Value::getType(), and llvm::CmpInst::makeCmpResultType().
Referenced by foldAndOrOfEqualityCmpsWithConstants().
|
static |
Return the set of patterns (from MaskedICmpType) that (icmp SCC (A & B), C) satisfies.
Definition at line 233 of file InstCombineAndOrXor.cpp.
References AMask_AllOnes, AMask_Mixed, AMask_NotAllOnes, AMask_NotMixed, B, BMask_AllOnes, BMask_Mixed, BMask_NotAllOnes, BMask_NotMixed, C, llvm::dyn_cast(), llvm::ConstantExpr::getAnd(), llvm::ConstantInt::getValue(), llvm::CmpInst::ICMP_EQ, llvm::APInt::isPowerOf2(), llvm::ConstantInt::isZero(), Mask_AllZeros, and Mask_NotAllZeros.
Referenced by getMaskedTypeForICmpPair().
|
static |
Handle (icmp(A & B) ==/!= C) &/| (icmp(A & D) ==/!= E).
Return the pattern classes (from MaskedICmpType) for the left hand side and the right hand side as a pair. LHS and RHS are the left hand side and the right hand side ICmps and PredL and PredR are their predicates, respectively.
Definition at line 314 of file InstCombineAndOrXor.cpp.
References llvm::decomposeBitTestICmp(), llvm::Constant::getAllOnesValue(), getMaskedICmpType(), llvm::User::getOperand(), llvm::Value::getType(), llvm::ICmpInst::isEquality(), llvm::Type::isIntegerTy(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::None, and R2.
Referenced by foldLogOpOfMaskedICmps().
|
static |
This is the complement of getICmpCode, which turns an opcode and two operands into either a constant true or false, or a brand new ICmp instruction.
The sign is passed in to determine which kind of predicate to use in the new icmp instruction.
Definition at line 56 of file InstCombineAndOrXor.cpp.
References llvm::IRBuilder< T, Inserter >::CreateICmp(), and llvm::getICmpValue().
Referenced by foldAndOrOfEqualityCmpsWithConstants(), foldXorToXor(), and matchSelectFromAndOr().
|
static |
We have an expression of the form (A & C) | (B & D).
If A is a scalar or vector composed of all-zeros or all-ones values and is the bitwise 'not' of B, it can be used as the condition operand of a select instruction.
Definition at line 1707 of file InstCombineAndOrXor.cpp.
References areInverseVectorBitmasks(), llvm::IRBuilder< T, Inserter >::CreateXor(), llvm::IRBuilder< T, Inserter >::CreateZExtOrTrunc(), llvm::ConstantExpr::getTrunc(), llvm::Value::getType(), llvm::Type::isIntOrIntVectorTy(), llvm::Type::isVectorTy(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_SExt(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Xor(), llvm::CmpInst::makeCmpResultType(), llvm::PatternMatch::match(), and llvm::peekThroughBitcast().
Referenced by matchSelectFromAndOr().
|
static |
Match De Morgan's Laws: (~A & ~B) == (~(A | B)) (~A | ~B) == (~(A & B))
Definition at line 1138 of file InstCombineAndOrXor.cpp.
References assert(), B, llvm::IRBuilder< T, Inserter >::CreateBinOp(), llvm::BinaryOperator::CreateNot(), llvm::CastInst::getDestTy(), llvm::Value::getName(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::CastInst::getSrcTy(), llvm::Value::hasOneUse(), llvm::IsFreeToInvert(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), and llvm::PatternMatch::match().
Referenced by llvm::InstCombiner::visitAnd(), and llvm::InstCombiner::visitOr().
|
static |
We have an expression of the form (A & C) | (B & D).
Try to simplify this to "A' ? C : D", where A' is a boolean or vector of booleans.
Definition at line 1751 of file InstCombineAndOrXor.cpp.
References assert(), B, llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilder< T, Inserter >::CreateSelect(), llvm::dyn_cast(), foldAndOrOfEqualityCmpsWithConstants(), foldLogOpOfMaskedICmps(), llvm::ConstantInt::get(), llvm::getICmpCode(), getNewICmpValue(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), getSelectCondition(), llvm::ConstantInt::getSigned(), llvm::ConstantInt::getType(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::Value::hasOneUse(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::ICmpInst::isEquality(), llvm::APInt::isPowerOf2(), llvm::CmpInst::isSigned(), llvm::ConstantInt::isZero(), llvm_unreachable, llvm::PatternMatch::m_Add(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::peekThroughBitcast(), llvm::PredicatesFoldable(), llvm::MCID::Select, llvm::APInt::sgt(), std::swap(), llvm::ICmpInst::swapOperands(), llvm::APInt::ugt(), and llvm::APInt::ult().
Referenced by llvm::InstCombiner::visitOr().
|
static |
Transform BITWISE_OP(BSWAP(A),BSWAP(B)) or BITWISE_OP(BSWAP(A), Constant) to BSWAP(BITWISE_OP(A, B))
| I | Binary operator to transform. |
Definition at line 83 of file InstCombineAndOrXor.cpp.
References llvm::MCID::Add, assert(), llvm::APInt::byteSwap(), C, llvm::IRBuilder< T, Inserter >::CreateBinOp(), llvm::IRBuilder< T, Inserter >::CreateCall(), F(), llvm::ConstantInt::get(), llvm::Intrinsic::getDeclaration(), llvm::ConstantInt::getFalse(), llvm::Instruction::getModule(), llvm::Value::getName(), llvm::BinaryOperator::getOpcode(), llvm::User::getOperand(), llvm::ICmpInst::getSignedPredicate(), llvm::ConstantInt::getTrue(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::Value::hasOneUse(), llvm::MipsISD::Hi, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_ULT, llvm::Instruction::isBitwiseLogicOp(), llvm::APInt::isMinSignedValue(), llvm::APInt::isMinValue(), llvm::APInt::isPowerOf2(), isSigned(), llvm::MipsISD::Lo, llvm::PatternMatch::m_APInt(), llvm::PatternMatch::m_BSwap(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::User::setOperand(), llvm::APInt::sle(), llvm::Value::takeName(), llvm::APInt::ule(), and X.
Referenced by llvm::InstCombiner::visitAnd(), llvm::InstCombiner::visitOr(), and llvm::InstCombiner::visitXor().
|
static |
If we have a masked merge, in the canonical form of: (assuming that A only has one use.) | A | |B| ((x ^ y) & M) ^ y | D |.
Definition at line 2425 of file InstCombineAndOrXor.cpp.
References B, C, llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::IRBuilder< T, Inserter >::CreateNot(), D, llvm::Value::hasOneUse(), llvm::PatternMatch::m_c_And(), llvm::PatternMatch::m_c_Xor(), llvm::PatternMatch::m_CombineAnd(), llvm::PatternMatch::m_Constant(), llvm::PatternMatch::m_Deferred(), llvm::PatternMatch::m_Not(), llvm::PatternMatch::m_OneUse(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and X.
Referenced by llvm::InstCombiner::visitXor().
1.8.13