21 using namespace PatternMatch;
23 #define DEBUG_TYPE "instcombine"
29 if (
Constant *C = dyn_cast<Constant>(V)) {
30 if (isConstant)
return true;
33 if (
Constant *Op0 = C->getAggregateElement(0U)) {
36 if (C->getAggregateElement(i) != Op0)
46 if (I->
getOpcode() == Instruction::InsertElement && isConstant &&
52 if (BO->hasOneUse() &&
56 if (
CmpInst *CI = dyn_cast<CmpInst>(I))
57 if (CI->hasOneUse() &&
78 if (PHIUser == cast<Instruction>(&EI))
79 PHIUser = cast<Instruction>(*(++iu));
90 PHINode *scalarPHI = cast<PHINode>(InsertNewInstWith(
98 if (PHIInVal == PHIUser) {
103 unsigned opId = (B0->
getOperand(0) == PN) ? 1 : 0;
104 Value *Op = InsertNewInstWith(
108 Value *newPHIUser = InsertNewInstWith(
117 if (pos && !isa<PHINode>(pos)) {
124 InsertNewInstWith(newEI, *InsertPos);
129 return ReplaceInstUsesWith(EI, scalarPHI);
135 return ReplaceInstUsesWith(EI, V);
141 return ReplaceInstUsesWith(EI, C->getAggregateElement(0U));
146 unsigned IndexVal = IdxC->getZExtValue();
150 assert(IndexVal < VectorWidth);
156 APInt UndefElts(VectorWidth, 0);
157 APInt DemandedMask(VectorWidth, 0);
158 DemandedMask.
setBit(IndexVal);
159 if (
Value *V = SimplifyDemandedVectorElts(EI.
getOperand(0), DemandedMask,
170 if (
VectorType *VT = dyn_cast<VectorType>(BCI->getOperand(0)->getType()))
171 if (VT->getNumElements() == VectorWidth)
189 if (
I->hasOneUse() &&
192 Builder->CreateExtractElement(BO->getOperand(0), EI.
getOperand(1),
195 Builder->CreateExtractElement(BO->getOperand(1), EI.
getOperand(1),
202 return ReplaceInstUsesWith(EI,
IE->getOperand(1));
205 if (isa<Constant>(
IE->getOperand(2)) && isa<Constant>(EI.
getOperand(1))) {
214 int SrcIdx = SVI->getMaskValue(Elt->getZExtValue());
221 if (SrcIdx < (
int)LHSWidth)
222 Src = SVI->getOperand(0);
225 Src = SVI->getOperand(1);
232 }
else if (
CastInst *CI = dyn_cast<CastInst>(
I)) {
235 if (CI->hasOneUse() && (CI->getOpcode() != Instruction::BitCast)) {
236 Value *EE = Builder->CreateExtractElement(CI->getOperand(0),
238 Worklist.AddValue(EE);
242 if (
SI->hasOneUse()) {
249 Value *TrueVal =
SI->getTrueValue();
250 Value *FalseVal =
SI->getFalseValue();
252 Value *Cond =
SI->getCondition();
254 Cond = Builder->CreateExtractElement(Cond,
260 = Builder->CreateExtractElement(TrueVal,
265 = Builder->CreateExtractElement(FalseVal,
271 SI->getName() +
".elt");
284 "Invalid CollectSingleShuffleElements");
287 if (isa<UndefValue>(V)) {
293 for (
unsigned i = 0; i != NumElts; ++i)
299 for (
unsigned i = 0; i != NumElts; ++i)
307 Value *VecOp = IEI->getOperand(0);
308 Value *ScalarOp = IEI->getOperand(1);
309 Value *IdxOp = IEI->getOperand(2);
311 if (!isa<ConstantInt>(IdxOp))
313 unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getZExtValue();
315 if (isa<UndefValue>(ScalarOp)) {
325 unsigned ExtractedIdx =
326 cast<ConstantInt>(EI->
getOperand(1))->getZExtValue();
336 Mask[InsertedIdx % NumElts] =
341 Mask[InsertedIdx % NumElts] =
343 ExtractedIdx + NumLHSElts);
368 Value *PermittedRHS) {
370 unsigned NumElts = cast<VectorType>(V->
getType())->getNumElements();
372 if (isa<UndefValue>(V)) {
374 return std::make_pair(
378 if (isa<ConstantAggregateZero>(V)) {
380 return std::make_pair(V,
nullptr);
385 Value *VecOp = IEI->getOperand(0);
386 Value *ScalarOp = IEI->getOperand(1);
387 Value *IdxOp = IEI->getOperand(2);
390 if (isa<ConstantInt>(EI->
getOperand(1)) && isa<ConstantInt>(IdxOp)) {
391 unsigned ExtractedIdx =
392 cast<ConstantInt>(EI->
getOperand(1))->getZExtValue();
393 unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getZExtValue();
397 if (EI->
getOperand(0) == PermittedRHS || PermittedRHS ==
nullptr) {
400 assert(LR.second ==
nullptr || LR.second == RHS);
402 if (LR.first->getType() != RHS->
getType()) {
405 for (
unsigned i = 0; i < NumElts; ++i)
407 return std::make_pair(V,
nullptr);
411 Mask[InsertedIdx % NumElts] =
413 NumLHSElts+ExtractedIdx);
414 return std::make_pair(LR.first, RHS);
417 if (VecOp == PermittedRHS) {
420 unsigned NumLHSElts =
422 for (
unsigned i = 0; i != NumElts; ++i)
425 i == InsertedIdx ? ExtractedIdx : NumLHSElts + i));
426 return std::make_pair(EI->
getOperand(0), PermittedRHS);
434 return std::make_pair(EI->
getOperand(0), PermittedRHS);
440 for (
unsigned i = 0; i != NumElts; ++i)
442 return std::make_pair(V,
nullptr);
453 bool IsRedundant =
false;
467 if (UserInsInst->getIndices() == FirstIndices) {
476 return ReplaceInstUsesWith(I, I.
getOperand(0));
486 if (isa<UndefValue>(ScalarOp) || isa<UndefValue>(IdxOp))
487 ReplaceInstUsesWith(IE, VecOp);
492 if (isa<ConstantInt>(EI->
getOperand(1)) && isa<ConstantInt>(IdxOp)) {
494 unsigned NumExtractVectorElts =
496 unsigned ExtractedIdx =
497 cast<ConstantInt>(EI->
getOperand(1))->getZExtValue();
498 unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getZExtValue();
500 if (ExtractedIdx >= NumExtractVectorElts)
501 return ReplaceInstUsesWith(IE, VecOp);
503 if (InsertedIdx >= NumInsertVectorElts)
508 if (EI->
getOperand(0) == VecOp && ExtractedIdx == InsertedIdx)
509 return ReplaceInstUsesWith(IE, VecOp);
519 if (LR.first != &IE && LR.second != &IE) {
521 if (LR.second ==
nullptr)
530 unsigned VWidth = cast<VectorType>(VecOp->
getType())->getNumElements();
531 APInt UndefElts(VWidth, 0);
533 if (
Value *V = SimplifyDemandedVectorElts(&IE, AllOnesEltMask, UndefElts)) {
535 return ReplaceInstUsesWith(IE, V);
545 unsigned Depth = 5) {
547 if (isa<Constant>(V))
552 if (!I)
return false;
558 if (Depth == 0)
return false;
561 case Instruction::Add:
562 case Instruction::FAdd:
563 case Instruction::Sub:
564 case Instruction::FSub:
565 case Instruction::Mul:
566 case Instruction::FMul:
567 case Instruction::UDiv:
568 case Instruction::SDiv:
569 case Instruction::FDiv:
570 case Instruction::URem:
571 case Instruction::SRem:
572 case Instruction::FRem:
573 case Instruction::Shl:
574 case Instruction::LShr:
575 case Instruction::AShr:
579 case Instruction::ICmp:
580 case Instruction::FCmp:
581 case Instruction::Trunc:
582 case Instruction::ZExt:
583 case Instruction::SExt:
584 case Instruction::FPToUI:
585 case Instruction::FPToSI:
586 case Instruction::UIToFP:
587 case Instruction::SIToFP:
588 case Instruction::FPTrunc:
589 case Instruction::FPExt:
590 case Instruction::GetElementPtr: {
597 case Instruction::InsertElement: {
599 if (!CI)
return false;
604 bool SeenOnce =
false;
605 for (
int i = 0, e = Mask.
size(); i != e; ++i) {
606 if (Mask[i] == ElementNumber) {
624 case Instruction::Add:
625 case Instruction::FAdd:
626 case Instruction::Sub:
627 case Instruction::FSub:
628 case Instruction::Mul:
629 case Instruction::FMul:
630 case Instruction::UDiv:
631 case Instruction::SDiv:
632 case Instruction::FDiv:
633 case Instruction::URem:
634 case Instruction::SRem:
635 case Instruction::FRem:
636 case Instruction::Shl:
637 case Instruction::LShr:
638 case Instruction::AShr:
643 assert(NewOps.
size() == 2 &&
"binary operator with #ops != 2");
646 NewOps[0], NewOps[1],
"", BO);
647 if (isa<OverflowingBinaryOperator>(BO)) {
651 if (isa<PossiblyExactOperator>(BO)) {
652 New->setIsExact(BO->
isExact());
654 if (isa<FPMathOperator>(BO))
655 New->copyFastMathFlags(I);
658 case Instruction::ICmp:
659 assert(NewOps.
size() == 2 &&
"icmp with #ops != 2");
660 return new ICmpInst(I, cast<ICmpInst>(I)->getPredicate(),
661 NewOps[0], NewOps[1]);
662 case Instruction::FCmp:
663 assert(NewOps.
size() == 2 &&
"fcmp with #ops != 2");
664 return new FCmpInst(I, cast<FCmpInst>(I)->getPredicate(),
665 NewOps[0], NewOps[1]);
666 case Instruction::Trunc:
667 case Instruction::ZExt:
668 case Instruction::SExt:
669 case Instruction::FPToUI:
670 case Instruction::FPToSI:
671 case Instruction::UIToFP:
672 case Instruction::SIToFP:
673 case Instruction::FPTrunc:
674 case Instruction::FPExt: {
679 NewOps[0]->getType()->getVectorNumElements());
680 assert(NewOps.
size() == 1 &&
"cast with #ops != 1");
684 case Instruction::GetElementPtr: {
685 Value *Ptr = NewOps[0];
688 cast<GetElementPtrInst>(I)->getSourceElementType(), Ptr, Idx,
"", I);
689 GEP->
setIsInBounds(cast<GetElementPtrInst>(I)->isInBounds());
701 if (isa<UndefValue>(V)) {
705 if (isa<ConstantAggregateZero>(V)) {
710 if (
Constant *C = dyn_cast<Constant>(V)) {
712 for (
int i = 0, e = Mask.
size(); i != e; ++i) {
716 MaskValues.
push_back(Builder->getInt32(Mask[i]));
724 case Instruction::Add:
725 case Instruction::FAdd:
726 case Instruction::Sub:
727 case Instruction::FSub:
728 case Instruction::Mul:
729 case Instruction::FMul:
730 case Instruction::UDiv:
731 case Instruction::SDiv:
732 case Instruction::FDiv:
733 case Instruction::URem:
734 case Instruction::SRem:
735 case Instruction::FRem:
736 case Instruction::Shl:
737 case Instruction::LShr:
738 case Instruction::AShr:
742 case Instruction::ICmp:
743 case Instruction::FCmp:
744 case Instruction::Trunc:
745 case Instruction::ZExt:
746 case Instruction::SExt:
747 case Instruction::FPToUI:
748 case Instruction::FPToSI:
749 case Instruction::UIToFP:
750 case Instruction::SIToFP:
751 case Instruction::FPTrunc:
752 case Instruction::FPExt:
754 case Instruction::GetElementPtr: {
767 case Instruction::InsertElement: {
768 int Element = cast<ConstantInt>(I->
getOperand(2))->getLimitedValue();
775 for (
int e = Mask.
size(); Index != e; ++Index) {
776 if (Mask[Index] == Element) {
785 return EvaluateInDifferentElementOrder(I->
getOperand(0), Mask);
789 Builder->getInt32(Index),
"",
I);
796 bool &isLHSID,
bool &isRHSID) {
797 isLHSID = isRHSID =
true;
799 for (
unsigned i = 0, e = Mask.
size(); i != e; ++i) {
800 if (Mask[i] < 0)
continue;
802 isLHSID &= (Mask[i] == (
int)i);
805 isRHSID &= (Mask[i]-e == i);
819 unsigned MaskElems = Mask.
size();
820 unsigned BegIdx = Mask.
front();
821 unsigned EndIdx = Mask.
back();
822 if (BegIdx > EndIdx || EndIdx >= LHSElems || EndIdx - BegIdx != MaskElems - 1)
824 for (
unsigned I = 0; I != MaskElems; ++
I)
825 if (static_cast<unsigned>(Mask[I]) != BegIdx + I)
836 bool MadeChange =
false;
842 unsigned VWidth = cast<VectorType>(SVI.
getType())->getNumElements();
844 APInt UndefElts(VWidth, 0);
846 if (
Value *V = SimplifyDemandedVectorElts(&SVI, AllOnesEltMask, UndefElts)) {
848 return ReplaceInstUsesWith(SVI, V);
854 unsigned LHSWidth = cast<VectorType>(LHS->
getType())->getNumElements();
858 if (LHS == RHS || isa<UndefValue>(LHS)) {
859 if (isa<UndefValue>(LHS) && LHS == RHS) {
861 Value *Result = (VWidth == LHSWidth)
863 return ReplaceInstUsesWith(SVI, Result);
868 for (
unsigned i = 0, e = LHSWidth; i != VWidth; ++i) {
874 if ((Mask[i] >= (
int)e && isa<UndefValue>(RHS)) ||
875 (Mask[i] < (
int)e && isa<UndefValue>(LHS))) {
879 Mask[i] = Mask[i] % e;
891 if (VWidth == LHSWidth) {
893 bool isLHSID, isRHSID;
897 if (isLHSID)
return ReplaceInstUsesWith(SVI, LHS);
898 if (isRHSID)
return ReplaceInstUsesWith(SVI, RHS);
902 Value *V = EvaluateInDifferentElementOrder(LHS, Mask);
903 return ReplaceInstUsesWith(SVI, V);
937 unsigned MaskElems = Mask.
size();
938 unsigned BegIdx = Mask.
front();
942 assert(SrcElemBitWidth &&
"vector elements must have a bitwidth");
948 if (!BC->use_empty())
952 Type *TgtTy = BC->getDestTy();
953 unsigned TgtElemBitWidth =
DL.getTypeSizeInBits(TgtTy);
954 if (!TgtElemBitWidth)
956 unsigned TgtNumElems = VecBitWidth / TgtElemBitWidth;
957 bool VecBitWidthsEqual = VecBitWidth == TgtNumElems * TgtElemBitWidth;
958 bool BegIsAligned = 0 == ((SrcElemBitWidth * BegIdx) % TgtElemBitWidth);
959 if (!VecBitWidthsEqual)
969 for (
unsigned I = 0, E = MaskElems, Idx = BegIdx; I != E; ++Idx, ++
I)
976 unsigned SrcElemsPerTgtElem = TgtElemBitWidth / SrcElemBitWidth;
977 assert(SrcElemsPerTgtElem);
978 BegIdx /= SrcElemsPerTgtElem;
979 bool BCAlreadyExists = NewBCs.
find(CastSrcTy) != NewBCs.
end();
983 : Builder->CreateBitCast(V, CastSrcTy, SVI.
getName() +
".bc");
984 if (!BCAlreadyExists)
985 NewBCs[CastSrcTy] = NewBC;
986 auto *
Ext = Builder->CreateExtractElement(
990 ReplaceInstUsesWith(*BC,
Ext);
1041 if (!isa<UndefValue>(LHSShuffle->
getOperand(1)) && !isa<UndefValue>(RHS))
1042 LHSShuffle =
nullptr;
1044 if (!isa<UndefValue>(RHSShuffle->getOperand(1)))
1045 RHSShuffle =
nullptr;
1046 if (!LHSShuffle && !RHSShuffle)
1047 return MadeChange ? &SVI :
nullptr;
1049 Value* LHSOp0 =
nullptr;
1050 Value* LHSOp1 =
nullptr;
1051 Value* RHSOp0 =
nullptr;
1052 unsigned LHSOp0Width = 0;
1053 unsigned RHSOp0Width = 0;
1057 LHSOp0Width = cast<VectorType>(LHSOp0->
getType())->getNumElements();
1060 RHSOp0 = RHSShuffle->getOperand(0);
1061 RHSOp0Width = cast<VectorType>(RHSOp0->
getType())->getNumElements();
1063 Value* newLHS = LHS;
1064 Value* newRHS = RHS;
1067 if (isa<UndefValue>(RHS)) {
1072 else if (LHSOp0Width == LHSWidth) {
1077 if (RHSShuffle && RHSOp0Width == LHSWidth) {
1081 if (LHSOp0 == RHSOp0) {
1086 if (newLHS == LHS && newRHS == RHS)
1087 return MadeChange ? &SVI :
nullptr;
1093 if (RHSShuffle && newRHS != RHS)
1094 RHSMask = RHSShuffle->getShuffleMask();
1096 unsigned newLHSWidth = (newLHS != LHS) ? LHSOp0Width : LHSWidth;
1098 bool isSplat =
true;
1102 for (
unsigned i = 0; i < VWidth; ++i) {
1107 }
else if (Mask[i] < (
int)LHSWidth) {
1112 if (newLHS != LHS) {
1113 eltMask = LHSMask[Mask[i]];
1116 if (eltMask >= (
int)LHSOp0Width && isa<UndefValue>(LHSOp1))
1125 if (isa<UndefValue>(RHS))
1129 else if (newRHS != RHS) {
1130 eltMask = RHSMask[Mask[i]-LHSWidth];
1133 if (eltMask >= (
int)RHSOp0Width) {
1134 assert(isa<UndefValue>(RHSShuffle->getOperand(1))
1135 &&
"should have been check above");
1139 eltMask = Mask[i]-LHSWidth;
1147 if (eltMask >= 0 && newRHS !=
nullptr && newLHS != newRHS)
1148 eltMask += newLHSWidth;
1153 if (SplatElt >= 0 && SplatElt != eltMask)
1163 if (isSplat || newMask == LHSMask || newMask == RHSMask || newMask == Mask) {
1165 for (
unsigned i = 0, e = newMask.
size(); i != e; ++i) {
1166 if (newMask[i] < 0) {
1179 bool isLHSID, isRHSID;
1181 if (isLHSID && VWidth == LHSOp0Width)
return ReplaceInstUsesWith(SVI, newLHS);
1182 if (isRHSID && VWidth == RHSOp0Width)
return ReplaceInstUsesWith(SVI, newRHS);
1184 return MadeChange ? &SVI :
nullptr;
Instruction * visitInsertValueInst(InsertValueInst &IV)
Try to find redundant insertvalue instructions, like the following ones: %0 = insertvalue { i8...
void push_back(const T &Elt)
This class is the base class for the comparison instructions.
void addIncoming(Value *V, BasicBlock *BB)
addIncoming - Add an incoming value to the end of the PHI list
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
ArrayRef< unsigned > getIndices() const
bool hasNUses(unsigned N) const
Return true if this Value has exactly N users.
void setBit(unsigned bitPosition)
Set a given bit to 1.
unsigned getNumOperands() const
static ConstantAggregateZero * get(Type *Ty)
std::pair< Value *, Value * > ShuffleOps
We are building a shuffle to create V, which is a sequence of insertelement, extractelement pairs...
ShuffleVectorInst - This instruction constructs a fixed permutation of two input vectors.
static bool isShuffleExtractingFromLHS(ShuffleVectorInst &SVI, SmallVector< int, 16 > &Mask)
static void RecognizeIdentityMask(const SmallVectorImpl< int > &Mask, bool &isLHSID, bool &isRHSID)
StringRef getName() const
Return a constant reference to the value's name.
static InsertElementInst * Create(Value *Vec, Value *NewElt, Value *Idx, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
SelectInst - This class represents the LLVM 'select' instruction.
This is the base class for all instructions that perform data casts.
static Value * BuildNew(Instruction *I, ArrayRef< Value * > NewOps)
Rebuild a new instruction just like 'I' but with the new operands given.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void setIsInBounds(bool b=true)
setIsInBounds - Set or clear the inbounds flag on this GEP instruction.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
static Constant * get(ArrayRef< Constant * > V)
unsigned getBitWidth() const
Return the number of bits in the Vector type.
static bool CanEvaluateShuffled(Value *V, ArrayRef< int > Mask, unsigned Depth=5)
Return true if we can evaluate the specified expression tree if the vector elements were shuffled in ...
void assign(size_type NumElts, const T &Elt)
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
VectorType * getType() const
getType - Overload to return most specific vector type.
ArrayRef< T > slice(unsigned N) const
slice(n) - Chop off the first N elements of the array.
static bool isValidElementType(Type *ElemTy)
isValidElementType - Return true if the specified type is valid as a element type.
This instruction compares its operands according to the predicate given to the constructor.
uint64_t getLimitedValue(uint64_t Limit=~0ULL) const
getLimitedValue - If the value is smaller than the specified limit, return it, otherwise return the l...
This class represents a no-op cast from one type to another.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Instruction * visitExtractElementInst(ExtractElementInst &EI)
unsigned getNumElements() const
Return the number of elements in the Vector type.
Type * getElementType() const
size_t size() const
size - Get the array size.
unsigned getNumIncomingValues() const
getNumIncomingValues - Return the number of incoming edges
Value * findScalarElement(Value *V, unsigned EltNo)
Given a vector and an element number, see if the scalar value is already around as a register...
Instruction * visitInsertElementInst(InsertElementInst &IE)
GetElementPtrInst - an instruction for type-safe pointer arithmetic to access elements of arrays and ...
InsertElementInst - This instruction inserts a single (scalar) element into a VectorType value...
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
bool isVectorTy() const
isVectorTy - True if this is an instance of VectorType.
This is an important base class in LLVM.
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
static Constant * getShuffleVector(Constant *V1, Constant *V2, Constant *Mask, Type *OnlyIfReducedTy=nullptr)
BasicBlock * getIncomingBlock(unsigned i) const
getIncomingBlock - Return incoming basic block number i.
This instruction compares its operands according to the predicate given to the constructor.
static bool CheapToScalarize(Value *V, bool isConstant)
CheapToScalarize - Return true if the value is cheaper to scalarize than it is to leave as a vector o...
Value * getOperand(unsigned i) const
static bool CollectSingleShuffleElements(Value *V, Value *LHS, Value *RHS, SmallVectorImpl< Constant * > &Mask)
CollectSingleShuffleElements - If V is a shuffle of values that ONLY returns elements from either LHS...
static UndefValue * get(Type *T)
get() - Static factory methods - Return an 'undef' object of the specified type.
LLVMContext & getContext() const
All values hold a context through their type.
bool hasNoSignedWrap() const
Determine whether the no signed wrap flag is set.
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
BinaryOps getOpcode() const
This is the shared class of boolean and integer constants.
Value * getIncomingValue(unsigned i) const
getIncomingValue - Return incoming value number x
unsigned getVectorNumElements() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Type * getType() const
All values are typed, get the type of this value.
Instruction * user_back()
user_back - Specialize the methods defined in Value, as we know that an instruction can only be used ...
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.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
bool isExact() const
Determine whether the exact flag is set.
void setOperand(unsigned i, Value *Val)
VectorType - Class to represent vector types.
Value * SimplifyExtractElementInst(Value *Vec, Value *Idx, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr, const DominatorTree *DT=nullptr, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr)
Given operands for an ExtractElementInst, see if we can fold the result.
Class for arbitrary precision integers.
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.
iterator_range< user_iterator > users()
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)
const Type * getScalarType() const LLVM_READONLY
getScalarType - If this is a vector type, return the element type, otherwise return 'this'...
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)
Instruction * visitShuffleVectorInst(ShuffleVectorInst &SVI)
bool hasOneUse() const
Return true if there is exactly one user of this value.
iterator find(const KeyT &Val)
VectorType * getType() const
getType - Overload to return most specific vector type.
user_iterator user_begin()
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.
static VectorType * get(Type *ElementType, unsigned NumElements)
VectorType::get - This static method is the primary way to construct an VectorType.
static ShuffleOps CollectShuffleElements(Value *V, SmallVectorImpl< Constant * > &Mask, Value *PermittedRHS)
C - The default llvm calling convention, compatible with C.
iterator getFirstInsertionPt()
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
static void getShuffleMask(Constant *Mask, SmallVectorImpl< int > &Result)
getShuffleMask - Return the full mask for this instruction, where each element is the element number ...
InsertValueInst - This instruction inserts a struct field of array element value into an aggregate va...