20 using namespace PatternMatch;
22 #define DEBUG_TYPE "instcombine"
77 case Instruction::Add:
78 case Instruction::Mul:
83 case Instruction::Sub:
84 case Instruction::Shl:
85 case Instruction::LShr:
86 case Instruction::AShr:
98 case Instruction::Add:
99 case Instruction::Sub:
102 case Instruction::Shl:
103 case Instruction::LShr:
104 case Instruction::AShr:
108 case Instruction::Mul:
142 if (!isa<BinaryOperator>(TI))
146 Value *MatchOp, *OtherOpT, *OtherOpF;
152 MatchIsOpZero =
true;
157 MatchIsOpZero =
false;
164 MatchIsOpZero =
true;
169 MatchIsOpZero =
true;
206 if (
Instruction *TVI = dyn_cast<Instruction>(TrueVal)) {
207 if (TVI->hasOneUse() && TVI->getNumOperands() == 2 &&
208 !isa<Constant>(FalseVal)) {
210 unsigned OpToFold = 0;
211 if ((SFO & 1) && FalseVal == TVI->getOperand(0)) {
213 }
else if ((SFO & 2) && FalseVal == TVI->getOperand(1)) {
219 Value *OOp = TVI->getOperand(2-OpToFold);
222 if (!isa<Constant>(OOp) ||
isSelect01(C, cast<Constant>(OOp))) {
228 if (isa<PossiblyExactOperator>(BO))
230 if (isa<OverflowingBinaryOperator>(BO)) {
241 if (
Instruction *FVI = dyn_cast<Instruction>(FalseVal)) {
242 if (FVI->hasOneUse() && FVI->getNumOperands() == 2 &&
243 !isa<Constant>(TrueVal)) {
245 unsigned OpToFold = 0;
246 if ((SFO & 1) && TrueVal == FVI->getOperand(0)) {
248 }
else if ((SFO & 2) && TrueVal == FVI->getOperand(1)) {
254 Value *OOp = FVI->getOperand(2-OpToFold);
257 if (!isa<Constant>(OOp) ||
isSelect01(C, cast<Constant>(OOp))) {
263 if (isa<PossiblyExactOperator>(BO))
265 if (isa<OverflowingBinaryOperator>(BO)) {
311 bool OrOnTrueVal =
false;
316 if (!OrOnFalseVal && !OrOnTrueVal)
320 Value *
Y = OrOnFalseVal ? TrueVal : FalseVal;
326 V = Builder->
CreateShl(V, C2Log - C1Log);
327 }
else if (C1Log > C2Log) {
363 Value *Count = FalseVal;
364 Value *ValueOnZero = TrueVal;
402 bool Changed =
false;
413 if (
ConstantInt *CI = dyn_cast<ConstantInt>(CmpRHS)) {
433 if ((CmpLHS == TrueVal && AdjustedRHS == FalseVal) ||
434 (CmpLHS == FalseVal && AdjustedRHS == TrueVal))
449 sextRHS == FalseVal) {
451 AdjustedRHS = sextRHS;
453 sextRHS == TrueVal) {
455 AdjustedRHS = sextRHS;
463 zextRHS == FalseVal) {
465 AdjustedRHS = zextRHS;
467 zextRHS == TrueVal) {
469 AdjustedRHS = zextRHS;
478 CmpRHS = AdjustedRHS;
502 if (TrueVal->
getType() == Ty) {
503 if (
ConstantInt *Cmp = dyn_cast<ConstantInt>(CmpRHS)) {
517 if (C2->isAllOnesValue())
518 return ReplaceInstUsesWith(SI, Builder->
CreateOr(AShr, C1));
521 return ReplaceInstUsesWith(SI, Builder->
CreateAdd(And, C1));
529 if (CmpRHS != CmpLHS && isa<Constant>(CmpRHS)) {
542 unsigned BitWidth =
DL.getTypeSizeInBits(TrueVal->
getType());
547 bool IsBitTest =
false;
557 TrueWhenUnset =
false;
562 TrueWhenUnset =
true;
567 if (TrueWhenUnset && TrueVal == X &&
571 else if (!TrueWhenUnset && FalseVal == X &&
575 else if (TrueWhenUnset && FalseVal == X &&
579 else if (!TrueWhenUnset && TrueVal == X &&
584 return ReplaceInstUsesWith(SI, V);
589 return ReplaceInstUsesWith(SI, V);
591 if (
Value *V = foldSelectCttzCtlz(ICI, TrueVal, FalseVal, Builder))
592 return ReplaceInstUsesWith(SI, V);
594 return Changed ? &SI :
nullptr;
609 static bool CanSelectOperandBeMappingIntoPredBlock(
const Value *V,
620 if (
const PHINode *VP = dyn_cast<PHINode>(I))
621 if (VP->getParent() == CondPHI->
getParent())
642 if (C == A || C == B) {
646 return ReplaceInstUsesWith(Outer, Inner);
654 return ReplaceInstUsesWith(Outer, C);
660 APInt ACB = CB->getValue();
661 APInt ACC = CC->getValue();
669 return ReplaceInstUsesWith(Outer, Inner);
687 return ReplaceInstUsesWith(Outer, Inner);
697 return ReplaceInstUsesWith(Outer, NewSI);
700 auto IsFreeOrProfitableToInvert =
701 [&](
Value *V,
Value *&NotV,
bool &ElidesXor) {
717 Value *NotA, *NotB, *NotC;
718 bool ElidesXor =
false;
728 if (IsFreeOrProfitableToInvert(A, NotA, ElidesXor) &&
729 IsFreeOrProfitableToInvert(B, NotB, ElidesXor) &&
730 IsFreeOrProfitableToInvert(C, NotC, ElidesXor) && ElidesXor) {
742 return ReplaceInstUsesWith(Outer, NewOuter);
783 FalseVal->getValue() - Offset->
getValue());
789 !FalseVal->getValue().isPowerOf2()))
805 if (ValZeros > AndZeros)
806 V = Builder->
CreateShl(V, ValZeros - AndZeros);
807 else if (ValZeros < AndZeros)
808 V = Builder->
CreateLShr(V, AndZeros - ValZeros);
812 bool ShouldNotVal = !TrueVal->
isZero();
830 return ReplaceInstUsesWith(SI, V);
833 if (
ConstantInt *C = dyn_cast<ConstantInt>(TrueVal)) {
834 if (C->getZExtValue()) {
836 return BinaryOperator::CreateOr(CondVal, FalseVal);
840 return BinaryOperator::CreateAnd(NotCond, FalseVal);
842 if (
ConstantInt *C = dyn_cast<ConstantInt>(FalseVal)) {
843 if (!C->getZExtValue()) {
845 return BinaryOperator::CreateAnd(CondVal, TrueVal);
849 return BinaryOperator::CreateOr(NotCond, TrueVal);
854 if (CondVal == TrueVal)
855 return BinaryOperator::CreateOr(CondVal, FalseVal);
856 if (CondVal == FalseVal)
857 return BinaryOperator::CreateAnd(CondVal, TrueVal);
862 return BinaryOperator::CreateAnd(TrueVal, FalseVal);
864 return BinaryOperator::CreateOr(TrueVal, FalseVal);
868 if (
ConstantInt *TrueValC = dyn_cast<ConstantInt>(TrueVal))
869 if (
ConstantInt *FalseValC = dyn_cast<ConstantInt>(FalseVal)) {
871 if (FalseValC->isZero() && TrueValC->getValue() == 1)
875 if (FalseValC->isZero() && TrueValC->isAllOnesValue())
879 if (TrueValC->isZero() && FalseValC->getValue() == 1) {
885 if (TrueValC->isZero() && FalseValC->isAllOnesValue()) {
890 if (
Value *V = foldSelectICmpAnd(SI, TrueValC, FalseValC, Builder))
891 return ReplaceInstUsesWith(SI, V);
895 if (
FCmpInst *FCI = dyn_cast<FCmpInst>(CondVal)) {
896 if (FCI->getOperand(0) == TrueVal && FCI->getOperand(1) == FalseVal) {
903 if (((CFPt = dyn_cast<ConstantFP>(TrueVal)) &&
905 ((CFPf = dyn_cast<ConstantFP>(FalseVal)) &&
907 return ReplaceInstUsesWith(SI, FalseVal);
915 if (((CFPt = dyn_cast<ConstantFP>(TrueVal)) &&
917 ((CFPf = dyn_cast<ConstantFP>(FalseVal)) &&
919 return ReplaceInstUsesWith(SI, TrueVal);
937 }
else if (FCI->getOperand(0) == FalseVal && FCI->getOperand(1) == TrueVal){
944 if (((CFPt = dyn_cast<ConstantFP>(TrueVal)) &&
946 ((CFPf = dyn_cast<ConstantFP>(FalseVal)) &&
948 return ReplaceInstUsesWith(SI, FalseVal);
956 if (((CFPt = dyn_cast<ConstantFP>(TrueVal)) &&
958 ((CFPf = dyn_cast<ConstantFP>(FalseVal)) &&
960 return ReplaceInstUsesWith(SI, TrueVal);
983 if (
ICmpInst *ICI = dyn_cast<ICmpInst>(CondVal))
984 if (
Instruction *Result = visitSelectInstWithICmp(SI, ICI))
987 if (
Instruction *TI = dyn_cast<Instruction>(TrueVal))
988 if (
Instruction *FI = dyn_cast<Instruction>(FalseVal))
989 if (TI->hasOneUse() && FI->hasOneUse()) {
993 if (TI->getOpcode() == FI->getOpcode())
999 if ((TI->getOpcode() == Instruction::Sub &&
1000 FI->getOpcode() == Instruction::Add) ||
1001 (TI->getOpcode() == Instruction::FSub &&
1002 FI->getOpcode() == Instruction::FAdd)) {
1003 AddOp = FI; SubOp = TI;
1004 }
else if ((FI->getOpcode() == Instruction::Sub &&
1005 TI->getOpcode() == Instruction::Add) ||
1006 (FI->getOpcode() == Instruction::FSub &&
1007 TI->getOpcode() == Instruction::FAdd)) {
1008 AddOp = TI; SubOp = FI;
1012 Value *OtherAddOp =
nullptr;
1013 if (SubOp->getOperand(0) == AddOp->
getOperand(0)) {
1015 }
else if (SubOp->getOperand(0) == AddOp->
getOperand(1)) {
1024 NegVal = Builder->
CreateFNeg(SubOp->getOperand(1));
1025 if (
Instruction *NegInst = dyn_cast<Instruction>(NegVal)) {
1027 Flags &= SubOp->getFastMathFlags();
1028 NegInst->setFastMathFlags(Flags);
1031 NegVal = Builder->
CreateNeg(SubOp->getOperand(1));
1034 Value *NewTrueOp = OtherAddOp;
1035 Value *NewFalseOp = NegVal;
1040 NewFalseOp, SI.
getName() +
".p");
1044 BinaryOperator::CreateFAdd(SubOp->getOperand(0), NewSel);
1047 Flags &= SubOp->getFastMathFlags();
1058 if (
Instruction *FoldI = FoldSelectIntoOp(SI, TrueVal, FalseVal))
1061 Value *LHS, *RHS, *LHS2, *RHS2;
1074 return ReplaceInstUsesWith(SI, NewSI);
1082 if (
Instruction *R = FoldSPFofSPF(cast<Instruction>(LHS),SPF2,LHS2,RHS2,
1086 if (
Instruction *R = FoldSPFofSPF(cast<Instruction>(RHS),SPF2,LHS2,RHS2,
1113 return ReplaceInstUsesWith(SI, NewSI);
1125 if (CanSelectOperandBeMappingIntoPredBlock(TrueVal, SI) &&
1126 CanSelectOperandBeMappingIntoPredBlock(FalseVal, SI))
1130 if (
SelectInst *TrueSI = dyn_cast<SelectInst>(TrueVal)) {
1131 if (TrueSI->getCondition()->getType() == CondVal->
getType()) {
1133 if (TrueSI->getCondition() == CondVal) {
1142 if (TrueSI->getFalseValue() == FalseVal && TrueSI->
hasOneUse()) {
1150 if (
SelectInst *FalseSI = dyn_cast<SelectInst>(FalseVal)) {
1151 if (FalseSI->getCondition()->getType() == CondVal->
getType()) {
1153 if (FalseSI->getCondition() == CondVal) {
1160 if (FalseSI->getTrueValue() == TrueVal && FalseSI->
hasOneUse()) {
1177 unsigned VWidth = VecTy->getNumElements();
1178 APInt UndefElts(VWidth, 0);
1180 if (
Value *V = SimplifyDemandedVectorElts(&SI, AllOnesEltMask, UndefElts)) {
1182 return ReplaceInstUsesWith(SI, V);
1186 if (isa<ConstantAggregateZero>(CondVal)) {
1187 return ReplaceInstUsesWith(SI, FalseVal);
Value * CreateLShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
Instruction * FoldSPFofSPF(Instruction *Inner, SelectPatternFlavor SPF1, Value *A, Value *B, Instruction &Outer, SelectPatternFlavor SPF2, Value *C)
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
Value * CreateCast(Instruction::CastOps Op, Value *V, Type *DestTy, const Twine &Name="")
static APInt getSignBit(unsigned BitWidth)
Get the SignBit for a specific bit width.
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
static bool IsFreeToInvert(Value *V, bool WillInvertAllUses)
Return true if the specified value is free to invert (apply ~ to).
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name="")
match_zero m_Zero()
Match an arbitrary zero/null constant.
bool hasNUses(unsigned N) const
Return true if this Value has exactly N users.
unsigned getBitWidth() const
getBitWidth - Return the bitwidth of this constant.
This class represents zero extension of integer types.
unsigned getNumOperands() const
static Constant * GetSelectFoldableConstant(Instruction *I)
GetSelectFoldableConstant - For the same transformation as the previous function, return the identity...
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
1 1 1 0 True if unordered or not equal
static bool isEquality(Predicate P)
isEquality - Return true if this predicate is either EQ or NE.
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
This class represents a sign extension of integer types.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
static CmpInst::Predicate getICmpPredicateForMinMax(SelectPatternFlavor SPF)
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
static Constant * getNullValue(Type *Ty)
StringRef getName() const
Return a constant reference to the value's name.
SelectPatternFlavor matchSelectPattern(Value *V, Value *&LHS, Value *&RHS, Instruction::CastOps *CastOp=nullptr)
Pattern match integer [SU]MIN, [SU]MAX and ABS idioms, returning the kind and providing the out param...
bool match(Val *V, const Pattern &P)
Value * CreateXor(Value *LHS, Value *RHS, const Twine &Name="")
BinaryOp_match< LHS, RHS, Instruction::Xor > m_Xor(const LHS &L, const RHS &R)
SelectInst - This class represents the LLVM 'select' instruction.
const APInt & getValue() const
Return the constant as an APInt value reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
CastClass_match< OpTy, Instruction::Trunc > m_Trunc(const OpTy &Op)
Matches Trunc.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
static Constant * getSExt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static SelectPatternFlavor getInverseMinMaxSelectPattern(SelectPatternFlavor SPF)
Instruction * clone() const
clone() - Create a copy of 'this' instruction that is identical in all ways except the following: ...
not_match< LHS > m_Not(const LHS &L)
static Constant * getZExt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Value * CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
CastClass_match< OpTy, Instruction::ZExt > m_ZExt(const OpTy &Op)
Matches ZExt.
This instruction compares its operands according to the predicate given to the constructor.
bool sgt(const APInt &RHS) const
Signed greather than comparison.
class_match< ConstantInt > m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
cst_pred_ty< is_power2 > m_Power2()
Match an integer or vector power of 2.
Value * CreateAShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
void takeName(Value *V)
Transfer the name from V to this value.
static BinaryOperator * CreateAdd(Value *S1, Value *S2, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
static const Value * getNotArgument(const Value *BinOp)
bool ult(const APInt &RHS) const
Unsigned less than comparison.
void replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
bool isIntOrIntVectorTy() const
isIntOrIntVectorTy - Return true if this is an integer type or a vector of integer types...
apint_match m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt...
The instances of the Type class are immutable: once they are created, they are never changed...
BinaryOp_match< LHS, RHS, Instruction::Or > m_Or(const LHS &L, const RHS &R)
bool isVectorTy() const
isVectorTy - True if this is an instance of VectorType.
Value * CreateNot(Value *V, const Twine &Name="")
bool sge(const APInt &RHS) const
Signed greather or equal comparison.
bool isEquality() const
isEquality - Return true if this predicate is either EQ or NE.
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
This is an important base class in LLVM.
const Value * getCondition() const
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
ConstantFP - Floating Point Values [float, double].
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
cst_pred_ty< is_all_ones > m_AllOnes()
Match an integer or vector with all bits set to true.
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
bool sle(const APInt &RHS) const
Signed less or equal comparison.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
This instruction compares its operands according to the predicate given to the constructor.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
Instruction * FoldSelectIntoOp(SelectInst &SI, Value *, Value *)
FoldSelectIntoOp - Try fold the select into one of the operands to facilitate further optimization...
Value * getOperand(unsigned i) const
bool isCommutative() const
isCommutative - Return true if the instruction is commutative:
static bool isNot(const Value *V)
static Value * foldSelectICmpAndOr(const SelectInst &SI, Value *TrueVal, Value *FalseVal, InstCombiner::BuilderTy *Builder)
foldSelectICmpAndOr - We want to turn: (select (icmp eq (and X, C1), 0), Y, (or Y, C2)) into: (or (shl (and X, C1), C3), y) iff: C1 and C2 are both powers of 2 where: C3 = Log(C2) - Log(C1)
Class to represent integer types.
Predicate getPredicate() const
Return the predicate for this instruction.
Instruction * FoldSelectOpOp(SelectInst &SI, Instruction *TI, Instruction *FI)
FoldSelectOpOp - Here we have (select c, TI, FI), and we know that TI and FI have the same opcode and...
static Constant * getAllOnesValue(Type *Ty)
Get the all ones value.
Value * SimplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr, const DominatorTree *DT=nullptr, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr)
SimplifySelectInst - Given operands for a SelectInst, see if we can fold the result.
LLVMContext & getContext() const
bool isFPOrFPVectorTy() const
isFPOrFPVectorTy - Return true if this is a FP type or a vector of FP.
bool hasNoSignedWrap() const
Determine whether the no signed wrap flag is set.
const Value * getTrueValue() const
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag...
CastClass_match< OpTy, Instruction::SExt > m_SExt(const OpTy &Op)
Matches SExt.
bool ugt(const APInt &RHS) const
Unsigned greather than comparison.
BinaryOps getOpcode() const
Instruction * visitSelectInstWithICmp(SelectInst &SI, ICmpInst *ICI)
This is the shared class of boolean and integer constants.
bool slt(const APInt &RHS) const
Signed less than comparison.
unsigned getVectorNumElements() const
unsigned getScalarSizeInBits() const LLVM_READONLY
getScalarSizeInBits - If this is a vector type, return the getPrimitiveSizeInBits value for the eleme...
static Value * generateMinMaxSelectPattern(InstCombiner::BuilderTy *Builder, SelectPatternFlavor SPF, Value *A, Value *B)
unsigned logBase2() const
Type * getType() const
All values are typed, get the type of this value.
SelectPatternFlavor
Specific patterns of select instructions we can match.
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
bool isExact() const
Determine whether the exact flag is set.
Instruction * visitSelectInst(SelectInst &SI)
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
void setOperand(unsigned i, Value *Val)
bool isAllOnesValue() const
isAllOnesValue - Return true if this is the value that would be returned by getAllOnesValue.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
VectorType - Class to represent vector types.
Class for arbitrary precision integers.
bool isIntegerTy() const
isIntegerTy - True if this is an instance of IntegerType.
static BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), Instruction *InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="")
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
bool hasOneUse() const
Return true if there is exactly one user of this value.
void setArgOperand(unsigned i, Value *v)
bool hasNUsesOrMore(unsigned N) const
Return true if this value has N users or more.
const APFloat & getValueAPF() const
bool isUnsigned() const
Determine if this instruction is using an unsigned comparison.
user_iterator user_begin()
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
getPrimitiveSizeInBits - Return the basic size of this type if it is a primitive type.
0 0 0 1 True if ordered and equal
LLVM Value Representation.
bool hasNoUnsignedWrap() const
Determine whether the no unsigned wrap flag is set.
This file provides internal interfaces used to implement the InstCombine.
unsigned getOpcode() const
getOpcode() returns a member of one of the enums like Instruction::Add.
bool isZero() const
Returns true if and only if the float is plus or minus zero.
static bool isUnordered(unsigned short predicate)
Determine if the predicate is an unordered operation.
void moveBefore(Instruction *MovePos)
moveBefore - Unlink this instruction from its current basic block and insert it into the basic block ...
static bool isSelect01(Constant *C1, Constant *C2)
static unsigned GetSelectFoldableOperands(Instruction *I)
GetSelectFoldableOperands - We want to turn code that looks like this: C = or A, B D = select cond...
C - The default llvm calling convention, compatible with C.
const Value * getFalseValue() const
Convenience struct for specifying and reasoning about fast-math flags.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
specific_intval m_SpecificInt(uint64_t V)
Match a specific integer value or vector with all elements equal to the value.
Value * CreateFNeg(Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
const BasicBlock * getParent() const
bool isOne() const
This is just a convenience method to make client code smaller for a common case.
IntrinsicInst - A useful wrapper class for inspecting calls to intrinsic functions.