21 using namespace PatternMatch;
23 #define DEBUG_TYPE "instcombine"
85 case Instruction::Mul:
90 case Instruction::Sub:
91 case Instruction::Shl:
92 case Instruction::LShr:
93 case Instruction::AShr:
106 case Instruction::Sub:
109 case Instruction::Shl:
110 case Instruction::LShr:
111 case Instruction::AShr:
115 case Instruction::Mul:
146 if (TI->
getOpcode() != Instruction::BitCast &&
174 Value *MatchOp, *OtherOpT, *OtherOpF;
180 MatchIsOpZero =
true;
185 MatchIsOpZero =
false;
192 MatchIsOpZero =
true;
197 MatchIsOpZero =
true;
205 Value *Op0 = MatchIsOpZero ? MatchOp : NewSI;
206 Value *Op1 = MatchIsOpZero ? NewSI : MatchOp;
229 if (
Instruction *TVI = dyn_cast<Instruction>(TrueVal)) {
230 if (TVI->hasOneUse() && TVI->getNumOperands() == 2 &&
231 !isa<Constant>(FalseVal)) {
233 unsigned OpToFold = 0;
234 if ((SFO & 1) && FalseVal == TVI->getOperand(0)) {
236 }
else if ((SFO & 2) && FalseVal == TVI->getOperand(1)) {
242 Value *OOp = TVI->getOperand(2-OpToFold);
245 if (!isa<Constant>(OOp) ||
isSelect01(C, cast<Constant>(OOp))) {
259 if (
Instruction *FVI = dyn_cast<Instruction>(FalseVal)) {
260 if (FVI->hasOneUse() && FVI->getNumOperands() == 2 &&
261 !isa<Constant>(TrueVal)) {
263 unsigned OpToFold = 0;
264 if ((SFO & 1) && TrueVal == FVI->getOperand(0)) {
266 }
else if ((SFO & 2) && TrueVal == FVI->getOperand(1)) {
272 Value *OOp = FVI->getOperand(2-OpToFold);
275 if (!isa<Constant>(OOp) ||
isSelect01(C, cast<Constant>(OOp))) {
324 bool OrOnTrueVal =
false;
329 if (!OrOnFalseVal && !OrOnTrueVal)
333 Value *
Y = OrOnFalseVal ? TrueVal : FalseVal;
339 V = Builder->
CreateShl(V, C2Log - C1Log);
340 }
else if (C1Log > C2Log) {
376 Value *Count = FalseVal;
377 Value *ValueOnZero = TrueVal;
442 if ((CmpLHS == TrueVal && AdjustedRHS == FalseVal) ||
443 (CmpLHS == FalseVal && AdjustedRHS == TrueVal)) {
458 AdjustedRHS = SextRHS;
460 SextRHS == TrueVal) {
462 AdjustedRHS = SextRHS;
471 AdjustedRHS = ZextRHS;
473 ZextRHS == TrueVal) {
475 AdjustedRHS = ZextRHS;
487 CmpRHS = AdjustedRHS;
526 default:
return nullptr;
530 if (isa<Constant>(LHS))
544 if (
Instruction *NewSel = canonicalizeMinMaxWithConstant(SI, *ICI, *Builder))
547 bool Changed = adjustMinMax(SI, *ICI);
561 if (TrueVal->
getType() == Ty) {
562 if (
ConstantInt *Cmp = dyn_cast<ConstantInt>(CmpRHS)) {
576 if (C2->isAllOnesValue())
577 return replaceInstUsesWith(SI, Builder->
CreateOr(AShr, C1));
580 return replaceInstUsesWith(SI, Builder->
CreateAdd(And, C1));
588 if (CmpRHS != CmpLHS && isa<Constant>(CmpRHS)) {
609 bool IsBitTest =
false;
619 TrueWhenUnset =
false;
624 TrueWhenUnset =
true;
629 if (TrueWhenUnset && TrueVal == X &&
633 else if (!TrueWhenUnset && FalseVal == X &&
637 else if (TrueWhenUnset && FalseVal == X &&
641 else if (!TrueWhenUnset && TrueVal == X &&
646 return replaceInstUsesWith(SI, V);
651 return replaceInstUsesWith(SI, V);
653 if (
Value *V = foldSelectCttzCtlz(ICI, TrueVal, FalseVal, Builder))
654 return replaceInstUsesWith(SI, V);
656 return Changed ? &SI :
nullptr;
670 static bool canSelectOperandBeMappingIntoPredBlock(
const Value *V,
681 if (
const PHINode *VP = dyn_cast<PHINode>(I))
682 if (VP->getParent() == CondPHI->
getParent())
706 if (C == A || C == B) {
710 return replaceInstUsesWith(Outer, Inner);
718 return replaceInstUsesWith(Outer, C);
722 const APInt *CB, *CC;
730 return replaceInstUsesWith(Outer, Inner);
747 return replaceInstUsesWith(Outer, Inner);
758 return replaceInstUsesWith(Outer, NewSI);
761 auto IsFreeOrProfitableToInvert =
762 [&](
Value *V,
Value *&NotV,
bool &ElidesXor) {
778 Value *NotA, *NotB, *NotC;
779 bool ElidesXor =
false;
789 if (IsFreeOrProfitableToInvert(A, NotA, ElidesXor) &&
790 IsFreeOrProfitableToInvert(B, NotB, ElidesXor) &&
791 IsFreeOrProfitableToInvert(C, NotC, ElidesXor) && ElidesXor) {
803 return replaceInstUsesWith(Outer, NewOuter);
844 FalseVal->getValue() - Offset->
getValue());
850 !FalseVal->getValue().isPowerOf2()))
866 if (ValZeros > AndZeros)
867 V = Builder->
CreateShl(V, ValZeros - AndZeros);
868 else if (ValZeros < AndZeros)
869 V = Builder->
CreateLShr(V, AndZeros - ValZeros);
873 bool ShouldNotVal = !TrueVal->
isZero();
893 if (!TI || !FI || !TI->
hasOneUse() || !FI->hasOneUse())
897 if ((TI->
getOpcode() == Instruction::Sub &&
900 FI->getOpcode() == Instruction::FAdd)) {
903 }
else if ((FI->getOpcode() == Instruction::Sub &&
905 (FI->getOpcode() == Instruction::FSub &&
912 Value *OtherAddOp =
nullptr;
913 if (SubOp->getOperand(0) == AddOp->
getOperand(0)) {
915 }
else if (SubOp->getOperand(0) == AddOp->
getOperand(1)) {
924 NegVal = Builder.
CreateFNeg(SubOp->getOperand(1));
925 if (
Instruction *NegInst = dyn_cast<Instruction>(NegVal)) {
927 Flags &= SubOp->getFastMathFlags();
928 NegInst->setFastMathFlags(Flags);
931 NegVal = Builder.
CreateNeg(SubOp->getOperand(1));
934 Value *NewTrueOp = OtherAddOp;
935 Value *NewFalseOp = NegVal;
943 BinaryOperator::CreateFAdd(SubOp->getOperand(0), NewSel);
946 Flags &= SubOp->getFastMathFlags();
963 if (ExtOpcode != Instruction::ZExt && ExtOpcode != Instruction::SExt)
984 Value *TruncCVal = cast<Value>(TruncC);
1026 for (
unsigned i = 0;
i != NumElts; ++
i) {
1037 }
else if (isa<UndefValue>(Elt)) {
1066 if (TVal == A || TVal == B || FVal == A || FVal == B)
1083 if (TSrc == C && FSrc == D) {
1087 }
else if (TSrc == D && FSrc == C) {
1105 return replaceInstUsesWith(SI, V);
1107 if (
Instruction *I = canonicalizeSelectToShuffle(SI))
1114 return BinaryOperator::CreateOr(CondVal, FalseVal);
1119 return BinaryOperator::CreateAnd(NotCond, FalseVal);
1123 return BinaryOperator::CreateAnd(CondVal, TrueVal);
1128 return BinaryOperator::CreateOr(NotCond, TrueVal);
1133 if (CondVal == TrueVal)
1134 return BinaryOperator::CreateOr(CondVal, FalseVal);
1135 if (CondVal == FalseVal)
1136 return BinaryOperator::CreateAnd(CondVal, TrueVal);
1141 return BinaryOperator::CreateAnd(TrueVal, FalseVal);
1143 return BinaryOperator::CreateOr(TrueVal, FalseVal);
1155 return new ZExtInst(CondVal, SelType);
1159 return new SExtInst(CondVal, SelType);
1164 return new ZExtInst(NotCond, SelType);
1170 return new SExtInst(NotCond, SelType);
1174 if (
ConstantInt *TrueValC = dyn_cast<ConstantInt>(TrueVal))
1175 if (
ConstantInt *FalseValC = dyn_cast<ConstantInt>(FalseVal))
1176 if (
Value *V = foldSelectICmpAnd(SI, TrueValC, FalseValC, Builder))
1177 return replaceInstUsesWith(SI, V);
1180 if (
FCmpInst *FCI = dyn_cast<FCmpInst>(CondVal)) {
1181 if (FCI->getOperand(0) == TrueVal && FCI->getOperand(1) == FalseVal) {
1188 if (((CFPt = dyn_cast<ConstantFP>(TrueVal)) &&
1190 ((CFPf = dyn_cast<ConstantFP>(FalseVal)) &&
1192 return replaceInstUsesWith(SI, FalseVal);
1200 if (((CFPt = dyn_cast<ConstantFP>(TrueVal)) &&
1202 ((CFPf = dyn_cast<ConstantFP>(FalseVal)) &&
1204 return replaceInstUsesWith(SI, TrueVal);
1224 }
else if (FCI->getOperand(0) == FalseVal && FCI->getOperand(1) == TrueVal){
1231 if (((CFPt = dyn_cast<ConstantFP>(TrueVal)) &&
1233 ((CFPf = dyn_cast<ConstantFP>(FalseVal)) &&
1235 return replaceInstUsesWith(SI, FalseVal);
1243 if (((CFPt = dyn_cast<ConstantFP>(TrueVal)) &&
1245 ((CFPf = dyn_cast<ConstantFP>(FalseVal)) &&
1247 return replaceInstUsesWith(SI, TrueVal);
1272 if (
ICmpInst *ICI = dyn_cast<ICmpInst>(CondVal))
1273 if (
Instruction *Result = foldSelectInstWithICmp(SI, ICI))
1282 if (TI && FI && TI->
getOpcode() == FI->getOpcode())
1291 if (
Instruction *FoldI = foldSelectIntoOp(SI, TrueVal, FalseVal))
1294 Value *LHS, *RHS, *LHS2, *RHS2;
1310 auto FMF = cast<FPMathOperator>(SI.
getCondition())->getFastMathFlags();
1318 return replaceInstUsesWith(SI, NewSI);
1330 if (
Instruction *R = foldSPFofSPF(cast<Instruction>(LHS),SPF2,LHS2,RHS2,
1334 if (
Instruction *R = foldSPFofSPF(cast<Instruction>(RHS),SPF2,LHS2,RHS2,
1350 if (NumberOfNots >= 2) {
1358 return replaceInstUsesWith(SI, NewSI);
1369 if (canSelectOperandBeMappingIntoPredBlock(TrueVal, SI) &&
1370 canSelectOperandBeMappingIntoPredBlock(FalseVal, SI))
1374 if (
SelectInst *TrueSI = dyn_cast<SelectInst>(TrueVal)) {
1375 if (TrueSI->getCondition()->getType() == CondVal->
getType()) {
1377 if (TrueSI->getCondition() == CondVal) {
1386 if (TrueSI->getFalseValue() == FalseVal && TrueSI->
hasOneUse()) {
1394 if (
SelectInst *FalseSI = dyn_cast<SelectInst>(FalseVal)) {
1395 if (FalseSI->getCondition()->getType() == CondVal->
getType()) {
1397 if (FalseSI->getCondition() == CondVal) {
1404 if (FalseSI->getTrueValue() == TrueVal && FalseSI->
hasOneUse()) {
1420 if (
VectorType *VecTy = dyn_cast<VectorType>(SelType)) {
1421 unsigned VWidth = VecTy->getNumElements();
1422 APInt UndefElts(VWidth, 0);
1424 if (
Value *V = SimplifyDemandedVectorElts(&SI, AllOnesEltMask, UndefElts)) {
1426 return replaceInstUsesWith(SI, V);
1430 if (isa<ConstantAggregateZero>(CondVal)) {
1431 return replaceInstUsesWith(SI, FalseVal);
1439 auto *PBI = dyn_cast_or_null<BranchInst>(Dom->getTerminator());
1440 if (PBI && PBI->isConditional() &&
1441 PBI->getSuccessor(0) != PBI->getSuccessor(1) &&
1442 (PBI->getSuccessor(0) == Parent || PBI->getSuccessor(1) == Parent)) {
1443 bool CondIsFalse = PBI->getSuccessor(1) == Parent;
1447 Value *V = *Implication ? TrueVal : FalseVal;
1448 return replaceInstUsesWith(SI, V);
1453 if (
Instruction *BitCastSel = foldSelectCmpBitcasts(SI, *Builder))
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
void push_back(const T &Elt)
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, 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).
class_match< CmpInst > m_Cmp()
Matches any compare instruction and ignore it.
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
DiagnosticInfoOptimizationBase::Argument NV
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateXor(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
bool isOneValue() const
Returns true if the value is one.
Value * CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name="")
class_match< Constant > m_Constant()
Match an arbitrary Constant and ignore it.
0 1 0 0 True if ordered and less than
This instruction constructs a fixed permutation of two input vectors.
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=nullptr, Instruction *MDFrom=nullptr)
1 1 1 0 True if unordered or not equal
static CastInst * CreateBitOrPointerCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
static bool isEquality(Predicate P)
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.
void reserve(size_type N)
bool Ordered
Only applicable if Flavor is SPF_FMINNUM or SPF_FMAXNUM.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
StringRef getName() const
Return a constant reference to the value's name.
Value * CreateNot(Value *V, const Twine &Name="")
void copyIRFlags(const Value *V)
Convenience method to copy supported wrapping, exact, and fast-math flags from V to this instruction...
bool match(Val *V, const Pattern &P)
BinaryOp_match< LHS, RHS, Instruction::Xor > m_Xor(const LHS &L, const RHS &R)
This class represents the LLVM 'select' instruction.
struct fuzzer::@269 Flags
const APInt & getValue() const
Return the constant as an APInt value reference.
static GCRegistry::Add< StatepointGC > D("statepoint-example","an example strategy for statepoint")
CastClass_match< OpTy, Instruction::Trunc > m_Trunc(const OpTy &Op)
Matches Trunc.
static Constant * get(ArrayRef< Constant * > V)
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)
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
static SelectPatternFlavor getInverseMinMaxSelectPattern(SelectPatternFlavor SPF)
Instruction * clone() const
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)
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.
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
class_match< ConstantInt > m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
cst_pred_ty< is_power2 > m_Power2()
Match an integer or vector power of 2.
void takeName(Value *V)
Transfer the name from V to this value.
Type * getScalarType() const LLVM_READONLY
If this is a vector type, return the element type, otherwise return 'this'.
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.
SelectPatternResult 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...
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
bool isIntOrIntVectorTy() const
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...
Value * CreateAShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
LLVM Basic Block Representation.
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
True if this is an instance of VectorType.
bool sge(const APInt &RHS) const
Signed greather or equal comparison.
bool isEquality() const
Return true if this predicate is either EQ or NE.
CastClass_match< OpTy, Instruction::BitCast > m_BitCast(const OpTy &Op)
Matches BitCast.
This is an important base class in LLVM.
const Value * getCondition() const
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
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.
bool isIntPredicate() const
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.
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
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.
Value * getOperand(unsigned i) const
bool isCommutative() const
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)
We want to turn: (select (icmp eq (and X, C1), 0), Y, (or Y, C2)) into: (or (shl (and X...
Class to represent integer types.
Predicate getPredicate() const
Return the predicate for this instruction.
Optional< bool > isImpliedCondition(const Value *LHS, const Value *RHS, const DataLayout &DL, bool InvertAPred=false, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Return true if RHS is known to be implied true by LHS.
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
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)
Given operands for a SelectInst, fold the result or return null.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
LLVMContext & getContext() const
LLVMContext & getContext() const
All values hold a context through their type.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
const Value * getTrueValue() const
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
void swapProfMetadata()
If the instruction has "branch_weights" MD_prof metadata and the MDNode has three operands (including...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
CastClass_match< OpTy, Instruction::SExt > m_SExt(const OpTy &Op)
Matches SExt.
bool ugt(const APInt &RHS) const
Unsigned greather than comparison.
0 0 1 0 True if ordered and greater than
BinaryOps getOpcode() const
This is the shared class of boolean and integer constants.
SelectPatternFlavor Flavor
bool slt(const APInt &RHS) const
Signed less than comparison.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
static Value * generateMinMaxSelectPattern(InstCombiner::BuilderTy *Builder, SelectPatternFlavor SPF, Value *A, Value *B)
unsigned logBase2() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
1 1 0 0 True if unordered or less than
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 * getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced=false)
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 isNullValue() const
Return true if this is the value that would be returned by getNullValue.
static ConstantInt * getTrue(LLVMContext &Context)
Instruction * visitSelectInst(SelectInst &SI)
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
void setOperand(unsigned i, Value *Val)
bool isAllOnesValue() const
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.
Class to represent vector types.
Class for arbitrary precision integers.
bool isIntegerTy() const
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.
BasicBlock * getSinglePredecessor()
Return the predecessor of this block if it has a single predecessor block.
unsigned getVectorNumElements() const
static Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
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 ...
static IntegerType * getInt32Ty(LLVMContext &C)
static bool isMinOrMax(SelectPatternFlavor SPF)
When implementing this min/max pattern as fcmp; select, does the fcmp have to be ordered?
static bool isUnordered(Predicate predicate)
Determine if the predicate is an unordered operation.
bool hasOneUse() const
Return true if there is exactly one user of this value.
void setArgOperand(unsigned i, Value *v)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
1 0 1 0 True if unordered or greater than
bool hasNUsesOrMore(unsigned N) const
Return true if this value has N users or more.
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
static Constant * getSelectFoldableConstant(Instruction *I)
For the same transformation as the previous function, return the identity constant that goes into the...
const APFloat & getValueAPF() const
Value * CreateCast(Instruction::CastOps Op, Value *V, Type *DestTy, const Twine &Name="")
bool isUnsigned() const
Determine if this instruction is using an unsigned comparison.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
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.
static CmpInst::Predicate getCmpPredicateForMinMax(SelectPatternFlavor SPF, bool Ordered=false)
This file provides internal interfaces used to implement the InstCombine.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
static unsigned getSelectFoldableOperands(Instruction *I)
We want to turn code that looks like this: C = or A, B D = select cond, C, A into: C = select cond...
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
void setFastMathFlags(FastMathFlags NewFMF)
Set the fast-math flags to be used with generated fp-math operators.
void moveBefore(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
static bool isSelect01(Constant *C1, Constant *C2)
Value * CreateLShr(Value *LHS, Value *RHS, const Twine &Name="", bool isExact=false)
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.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
const BasicBlock * getParent() const
Value * CreateFNeg(Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
bool isOne() const
This is just a convenience method to make client code smaller for a common case.
bind_ty< Instruction > m_Instruction(Instruction *&I)
Match an instruction, capturing it if we match.
A wrapper class for inspecting calls to intrinsic functions.