38 #define DEBUG_TYPE "instcombine" 55 FAddendCoef() =
default;
60 void operator=(
const FAddendCoef &A);
62 void operator*=(
const FAddendCoef &S);
65 assert(!insaneIntVal(
C) &&
"Insane coefficient");
76 bool isOne()
const {
return isInt() &&
IntVal == 1; }
77 bool isTwo()
const {
return isInt() &&
IntVal == 2; }
78 bool isMinusOne()
const {
return isInt() &&
IntVal == -1; }
79 bool isMinusTwo()
const {
return isInt() &&
IntVal == -2; }
82 bool insaneIntVal(
int V) {
return V > 4 || V < -4; }
85 {
return reinterpret_cast<APFloat *
>(&FpValBuf.buffer[0]); }
87 const APFloat *getFpValPtr()
const 88 {
return reinterpret_cast<const APFloat *
>(&FpValBuf.buffer[0]); }
90 const APFloat &getFpVal()
const {
91 assert(IsFp && BufHasFpVal &&
"Incorret state");
92 return *getFpValPtr();
96 assert(IsFp && BufHasFpVal &&
"Incorret state");
97 return *getFpValPtr();
100 bool isInt()
const {
return !IsFp; }
114 bool BufHasFpVal =
false;
133 assert((Val == T.Val) &&
"Symbolic-values disagree");
137 Value *getSymVal()
const {
return Val; }
138 const FAddendCoef &getCoef()
const {
return Coeff; }
140 bool isConstant()
const {
return Val ==
nullptr; }
141 bool isZero()
const {
return Coeff.isZero(); }
143 void set(
short Coefficient,
Value *V) {
144 Coeff.set(Coefficient);
148 Coeff.set(Coefficient);
152 Coeff.set(Coefficient->getValueAPF());
156 void negate() { Coeff.negate(); }
160 static unsigned drillValueDownOneStep(
Value* V, FAddend &A0, FAddend &A1);
164 unsigned drillAddendDownOneStep(FAddend &Addend0, FAddend &Addend1)
const;
167 void Scale(
const FAddendCoef& ScaleAmt) { Coeff *= ScaleAmt; }
170 Value *Val =
nullptr;
186 Value *simplifyFAdd(AddendVect& V,
unsigned InstrQuota);
189 Value *createAddendVal(
const FAddend &A,
bool& NeedNeg);
192 unsigned calcInstrNumber(
const AddendVect& Vect);
198 Value *createNaryFAdd(
const AddendVect& Opnds,
unsigned InstrQuota);
199 void createInstPostProc(
Instruction *NewInst,
bool NoNumber =
false);
203 unsigned CreateInstrNum;
204 void initCreateInstNum() { CreateInstrNum = 0; }
205 void incCreateInstNum() { CreateInstrNum++; }
207 void initCreateInstNum() {}
208 void incCreateInstNum() {}
223 FAddendCoef::~FAddendCoef() {
225 getFpValPtr()->~APFloat();
228 void FAddendCoef::set(
const APFloat&
C) {
238 IsFp = BufHasFpVal =
true;
241 void FAddendCoef::convertToFpType(
const fltSemantics &Sem) {
252 IsFp = BufHasFpVal =
true;
265 void FAddendCoef::operator=(
const FAddendCoef &That) {
269 set(That.getFpVal());
274 if (
isInt() == That.isInt()) {
278 getFpVal().add(That.getFpVal(), RndMode);
285 getFpVal().add(T, RndMode);
293 void FAddendCoef::operator*=(
const FAddendCoef &That) {
297 if (That.isMinusOne()) {
302 if (
isInt() && That.isInt()) {
303 int Res =
IntVal * (int)That.IntVal;
304 assert(!insaneIntVal(Res) &&
"Insane int value");
310 isInt() ? That.getFpVal().getSemantics() : getFpVal().getSemantics();
313 convertToFpType(Semantic);
317 F0.
multiply(createAPFloatFromInt(Semantic, That.IntVal),
323 void FAddendCoef::negate() {
327 getFpVal().changeSign();
330 Value *FAddendCoef::getValue(
Type *Ty)
const {
346 unsigned FAddend::drillValueDownOneStep
347 (
Value *Val, FAddend &Addend0, FAddend &Addend1) {
349 if (!Val || !(I = dyn_cast<Instruction>(Val)))
354 if (Opcode == Instruction::FAdd || Opcode == Instruction::FSub) {
358 if ((C0 = dyn_cast<ConstantFP>(Opnd0)) && C0->
isZero())
361 if ((C1 = dyn_cast<ConstantFP>(Opnd1)) && C1->
isZero())
366 Addend0.set(1, Opnd0);
368 Addend0.set(C0,
nullptr);
372 FAddend &Addend = Opnd0 ? Addend1 : Addend0;
374 Addend.set(1, Opnd1);
376 Addend.set(C1,
nullptr);
377 if (Opcode == Instruction::FSub)
382 return Opnd0 && Opnd1 ? 2 : 1;
389 if (I->
getOpcode() == Instruction::FMul) {
392 if (
ConstantFP *C = dyn_cast<ConstantFP>(V0)) {
397 if (
ConstantFP *C = dyn_cast<ConstantFP>(V1)) {
409 unsigned FAddend::drillAddendDownOneStep
410 (FAddend &Addend0, FAddend &Addend1)
const {
414 unsigned BreakNum = FAddend::drillValueDownOneStep(Val, Addend0, Addend1);
415 if (!BreakNum || Coeff.isOne())
418 Addend0.Scale(Coeff);
421 Addend1.Scale(Coeff);
428 "Expected 'reassoc'+'nsz' instruction");
435 I->
getOpcode() == Instruction::FSub) &&
"Expect add/sub");
440 FAddend Opnd0, Opnd1, Opnd0_0, Opnd0_1, Opnd1_0, Opnd1_1;
442 unsigned OpndNum = FAddend::drillValueDownOneStep(I, Opnd0, Opnd1);
445 unsigned Opnd0_ExpNum = 0;
446 unsigned Opnd1_ExpNum = 0;
448 if (!Opnd0.isConstant())
449 Opnd0_ExpNum = Opnd0.drillAddendDownOneStep(Opnd0_0, Opnd0_1);
452 if (OpndNum == 2 && !Opnd1.isConstant())
453 Opnd1_ExpNum = Opnd1.drillAddendDownOneStep(Opnd1_0, Opnd1_1);
456 if (Opnd0_ExpNum && Opnd1_ExpNum) {
458 AllOpnds.push_back(&Opnd0_0);
459 AllOpnds.push_back(&Opnd1_0);
460 if (Opnd0_ExpNum == 2)
461 AllOpnds.push_back(&Opnd0_1);
462 if (Opnd1_ExpNum == 2)
463 AllOpnds.push_back(&Opnd1_1);
466 unsigned InstQuota = 0;
470 InstQuota = ((!isa<Constant>(V0) && V0->
hasOneUse()) &&
471 (!isa<Constant>(V1) && V1->
hasOneUse())) ? 2 : 1;
473 if (
Value *R = simplifyFAdd(AllOpnds, InstQuota))
482 const FAddendCoef &CE = Opnd0.getCoef();
483 return CE.isOne() ? Opnd0.getSymVal() :
nullptr;
489 AllOpnds.push_back(&Opnd0);
490 AllOpnds.push_back(&Opnd1_0);
491 if (Opnd1_ExpNum == 2)
492 AllOpnds.push_back(&Opnd1_1);
494 if (
Value *R = simplifyFAdd(AllOpnds, 1))
501 AllOpnds.push_back(&Opnd1);
502 AllOpnds.push_back(&Opnd0_0);
503 if (Opnd0_ExpNum == 2)
504 AllOpnds.push_back(&Opnd0_1);
506 if (
Value *R = simplifyFAdd(AllOpnds, 1))
513 Value *FAddCombine::simplifyFAdd(AddendVect& Addends,
unsigned InstrQuota) {
514 unsigned AddendNum = Addends.size();
515 assert(AddendNum <= 4 &&
"Too many addends");
518 unsigned NextTmpIdx = 0;
519 FAddend TmpResult[3];
526 const FAddend *ConstAdd =
nullptr;
534 for (
unsigned SymIdx = 0; SymIdx < AddendNum; SymIdx++) {
536 const FAddend *ThisAddend = Addends[SymIdx];
542 Value *Val = ThisAddend->getSymVal();
543 unsigned StartIdx = SimpVect.size();
544 SimpVect.push_back(ThisAddend);
551 for (
unsigned SameSymIdx = SymIdx + 1;
552 SameSymIdx < AddendNum; SameSymIdx++) {
553 const FAddend *
T = Addends[SameSymIdx];
554 if (T && T->getSymVal() == Val) {
557 Addends[SameSymIdx] =
nullptr;
558 SimpVect.push_back(T);
563 if (StartIdx + 1 != SimpVect.size()) {
564 FAddend &R = TmpResult[NextTmpIdx ++];
565 R = *SimpVect[StartIdx];
566 for (
unsigned Idx = StartIdx + 1; Idx < SimpVect.size(); Idx++)
570 SimpVect.resize(StartIdx);
573 SimpVect.push_back(&R);
584 "out-of-bound access");
587 SimpVect.push_back(ConstAdd);
590 if (!SimpVect.empty())
591 Result = createNaryFAdd(SimpVect, InstrQuota);
600 Value *FAddCombine::createNaryFAdd
601 (
const AddendVect &Opnds,
unsigned InstrQuota) {
602 assert(!Opnds.empty() &&
"Expect at least one addend");
606 unsigned InstrNeeded = calcInstrNumber(Opnds);
607 if (InstrNeeded > InstrQuota)
620 Value *LastVal =
nullptr;
621 bool LastValNeedNeg =
false;
624 for (
const FAddend *Opnd : Opnds) {
626 Value *V = createAddendVal(*Opnd, NeedNeg);
629 LastValNeedNeg = NeedNeg;
633 if (LastValNeedNeg == NeedNeg) {
634 LastVal = createFAdd(LastVal, V);
639 LastVal = createFSub(V, LastVal);
641 LastVal = createFSub(LastVal, V);
643 LastValNeedNeg =
false;
646 if (LastValNeedNeg) {
647 LastVal = createFNeg(LastVal);
651 assert(CreateInstrNum == InstrNeeded &&
652 "Inconsistent in instruction numbers");
659 Value *V = Builder.CreateFSub(Opnd0, Opnd1);
661 createInstPostProc(I);
667 Value *NewV = createFSub(Zero, V);
669 createInstPostProc(I,
true);
674 Value *V = Builder.CreateFAdd(Opnd0, Opnd1);
676 createInstPostProc(I);
681 Value *V = Builder.CreateFMul(Opnd0, Opnd1);
683 createInstPostProc(I);
687 void FAddCombine::createInstPostProc(
Instruction *NewInstr,
bool NoNumber) {
700 unsigned FAddCombine::calcInstrNumber(
const AddendVect &Opnds) {
701 unsigned OpndNum = Opnds.size();
702 unsigned InstrNeeded = OpndNum - 1;
705 unsigned NegOpndNum = 0;
708 for (
const FAddend *Opnd : Opnds) {
709 if (Opnd->isConstant())
714 if (isa<UndefValue>(Opnd->getSymVal()))
717 const FAddendCoef &CE = Opnd->getCoef();
718 if (CE.isMinusOne() || CE.isMinusTwo())
724 if (!CE.isMinusOne() && !CE.isOne())
727 if (NegOpndNum == OpndNum)
740 Value *FAddCombine::createAddendVal(
const FAddend &Opnd,
bool &NeedNeg) {
741 const FAddendCoef &Coeff = Opnd.getCoef();
743 if (Opnd.isConstant()) {
745 return Coeff.getValue(Instr->getType());
748 Value *OpndVal = Opnd.getSymVal();
750 if (Coeff.isMinusOne() || Coeff.isOne()) {
751 NeedNeg = Coeff.isMinusOne();
755 if (Coeff.isTwo() || Coeff.isMinusTwo()) {
756 NeedNeg = Coeff.isMinusTwo();
757 return createFAdd(OpndVal, OpndVal);
761 return createFMul(OpndVal, Coeff.getValue(Instr->getType()));
775 if (!LHS->
hasOneUse() && !RHS->hasOneUse())
778 Value *
X =
nullptr, *
Y =
nullptr, *Z =
nullptr;
779 const APInt *C1 =
nullptr, *C2 =
nullptr;
795 return Builder.
CreateSub(RHS, NewAnd,
"sub");
800 return Builder.
CreateSub(RHS, NewOr,
"sub");
820 return Builder.
CreateSub(RHS, NewOr,
"sub");
837 const APInt *C1, *C2;
900 return BinaryOperator::CreateSub(
SubOne(Op1C),
X);
915 return BinaryOperator::CreateOr(Op0, Op1);
919 return BinaryOperator::CreateXor(Op0, Op1);
937 return new ZExtInst(Builder.CreateNot(X), Ty);
944 Value *NotX = Builder.CreateNot(X);
1019 (void)C0.
smul_ov(C1, overflow);
1021 (
void)C0.
umul_ov(C1, overflow);
1040 if (
MatchRem(MulOpV, RemOpV, C1, Rem2IsSigned) &&
1041 IsSigned == Rem2IsSigned) {
1045 if (
MatchDiv(RemOpV, DivOpV, DivOpC, IsSigned) && X == DivOpV &&
1049 return IsSigned ? Builder.CreateSRem(X, NewDivisor,
"srem")
1050 : Builder.CreateURem(X, NewDivisor,
"urem");
1073 if (
auto *BOp = dyn_cast<BinaryOperator>(NotMask)) {
1075 BOp->setHasNoSignedWrap();
1085 auto getUAddSat = [&]() {
1110 "Expecting add/or/sub instruction");
1127 bool HadTrunc = I.
getType() != XTy;
1150 auto SkipExtInMagic = [&
I](
Value *&V) {
1159 SkipExtInMagic(Select);
1163 Value *SignExtendingValue, *Zero;
1183 SkipExtInMagic(SignExtendingValue);
1184 Constant *SignExtendingValueBaseConstant;
1185 if (!
match(SignExtendingValue,
1191 ? !
match(SignExtendingValueBaseConstant,
m_One())
1195 auto *NewAShr = BinaryOperator::CreateAShr(X, LowBitsToSkip,
1196 Extract->
getName() +
".sext");
1197 NewAShr->copyIRFlags(Extract);
1201 Builder.Insert(NewAShr);
1208 SQ.getWithInstruction(&I)))
1209 return replaceInstUsesWith(I, V);
1211 if (SimplifyAssociativeOrCommutative(I))
1218 if (
Value *V = SimplifyUsingDistributiveLaws(I))
1219 return replaceInstUsesWith(I, V);
1231 if (
ConstantInt *CI = dyn_cast<ConstantInt>(RHS)) {
1235 const APInt &RHSVal = CI->getValue();
1236 unsigned ExtendAmt = 0;
1239 if (XorRHS->
getValue() == -RHSVal) {
1241 ExtendAmt = TySizeBits - RHSVal.
logBase2() - 1;
1254 Value *NewShl = Builder.CreateShl(XorLHS, ShAmt,
"sext");
1255 return BinaryOperator::CreateAShr(NewShl, ShAmt);
1262 if ((XorRHS->
getValue() | LHSKnown.
Zero).isAllOnesValue())
1275 return BinaryOperator::CreateXor(LHS, RHS);
1292 return BinaryOperator::CreateSub(RHS, A);
1297 return BinaryOperator::CreateSub(LHS, B);
1300 return replaceInstUsesWith(I, V);
1308 return BinaryOperator::CreateSub(A, B);
1311 if (
Value *V = SimplifyAddWithRemainder(I))
return replaceInstUsesWith(I, V);
1315 return BinaryOperator::CreateOr(LHS, RHS);
1320 if (
ConstantInt *CRHS = dyn_cast<ConstantInt>(RHS)) {
1326 CRHS->getValue() == (CRHS->getValue() & C2->
getValue())) {
1329 const APInt &AddRHSV = CRHS->getValue();
1332 APInt AddRHSHighBits(~((AddRHSV & -AddRHSV)-1));
1337 if (AddRHSHighBits == AddRHSHighBitsAnd) {
1339 Value *NewAdd = Builder.CreateAdd(X, CRHS, LHS->
getName());
1340 return BinaryOperator::CreateAnd(NewAdd, C2);
1377 return BinaryOperator::CreateOr(A, B);
1391 bool Changed =
false;
1405 canonicalizeCondSignextOfHighBitExtractToSignextHighBitExtract(I))
1411 return Changed ? &
I :
nullptr;
1434 I.
getOpcode() == Instruction::FSub) &&
"Expecting fadd/fsub");
1436 "FP factorization requires FMF");
1459 bool IsFAdd = I.
getOpcode() == Instruction::FAdd;
1476 SQ.getWithInstruction(&I)))
1477 return replaceInstUsesWith(I, V);
1479 if (SimplifyAssociativeOrCommutative(I))
1485 if (
Instruction *FoldedFAdd = foldBinOpIntoSelectOrPhi(I))
1498 Value *XY = Builder.CreateFMulFMF(X, Y, &I);
1507 Value *XY = Builder.CreateFDivFMF(X, Y, &I);
1514 if (
SIToFPInst *LHSConv = dyn_cast<SIToFPInst>(LHS)) {
1515 Value *LHSIntVal = LHSConv->getOperand(0);
1516 Type *FPType = LHSConv->getType();
1521 auto IsValidPromotion = [](
Type *FTy,
Type *ITy) {
1527 unsigned MaxRepresentableBits =
1537 if (
ConstantFP *CFP = dyn_cast<ConstantFP>(RHS))
1538 if (IsValidPromotion(FPType, LHSIntVal->
getType())) {
1541 if (LHSConv->hasOneUse() &&
1543 willNotOverflowSignedAdd(LHSIntVal, CI, I)) {
1545 Value *NewAdd = Builder.CreateNSWAdd(LHSIntVal, CI,
"addconv");
1551 if (
SIToFPInst *RHSConv = dyn_cast<SIToFPInst>(RHS)) {
1552 Value *RHSIntVal = RHSConv->getOperand(0);
1555 if (IsValidPromotion(FPType, LHSIntVal->
getType())) {
1560 (LHSConv->hasOneUse() || RHSConv->hasOneUse()) &&
1561 willNotOverflowSignedAdd(LHSIntVal, RHSIntVal, I)) {
1563 Value *NewAdd = Builder.CreateNSWAdd(LHSIntVal, RHSIntVal,
"addconv");
1571 if (
Value *V = SimplifySelectsFeedingBinaryOp(I, LHS, RHS))
1572 return replaceInstUsesWith(I, V);
1577 if (
Value *V = FAddCombine(Builder).simplify(&I))
1578 return replaceInstUsesWith(I, V);
1588 Type *Ty,
bool IsNUW) {
1591 bool Swapped =
false;
1596 if (
GEPOperator *LHSGEP = dyn_cast<GEPOperator>(LHS)) {
1598 if (LHSGEP->getOperand(0) == RHS) {
1601 }
else if (
GEPOperator *RHSGEP = dyn_cast<GEPOperator>(RHS)) {
1603 if (LHSGEP->getOperand(0)->stripPointerCasts() ==
1604 RHSGEP->getOperand(0)->stripPointerCasts()) {
1612 if (
GEPOperator *RHSGEP = dyn_cast<GEPOperator>(RHS)) {
1614 if (RHSGEP->getOperand(0) == LHS) {
1617 }
else if (
GEPOperator *LHSGEP = dyn_cast<GEPOperator>(LHS)) {
1619 if (RHSGEP->getOperand(0)->stripPointerCasts() ==
1620 LHSGEP->getOperand(0)->stripPointerCasts()) {
1645 unsigned NumNonConstantIndices2 = GEP2->countNonConstantIndices();
1646 if (NumNonConstantIndices1 + NumNonConstantIndices2 > 1 &&
1647 ((NumNonConstantIndices1 > 0 && !GEP1->
hasOneUse()) ||
1648 (NumNonConstantIndices2 > 0 && !GEP2->hasOneUse()))) {
1660 if (IsNUW && !GEP2 && !Swapped && GEP1->
isInBounds() &&
1669 Result = Builder.CreateSub(Result, Offset);
1674 Result = Builder.CreateNeg(Result,
"diff.neg");
1676 return Builder.CreateIntCast(Result, Ty,
true);
1682 SQ.getWithInstruction(&I)))
1683 return replaceInstUsesWith(I, V);
1689 if (
Value *V = SimplifyUsingDistributiveLaws(I))
1690 return replaceInstUsesWith(I, V);
1694 if (
Value *V = dyn_castNegVal(Op1)) {
1697 if (
const auto *BO = dyn_cast<BinaryOperator>(Op1)) {
1698 assert(BO->getOpcode() == Instruction::Sub &&
1699 "Expected a subtraction operator!");
1703 if (cast<Constant>(Op1)->isNotMinSignedValue() && I.
hasNoSignedWrap())
1711 return BinaryOperator::CreateXor(Op0, Op1);
1720 return BinaryOperator::CreateSub(Y, X);
1736 if (
Constant *C = dyn_cast<Constant>(Op0)) {
1764 if (
PHINode *PN = dyn_cast<PHINode>(Op1))
1785 bool HadTrunc = Op1Wide != Op1;
1786 bool NoTruncOrTruncIsOneUse = !HadTrunc || Op1->hasOneUse();
1792 if (NoTruncOrTruncIsOneUse &&
1794 *ShAmt == BitWidth - 1) {
1795 Value *ShAmtOp = cast<Instruction>(Op1Wide)->getOperand(1);
1796 Instruction *NewShift = BinaryOperator::CreateAShr(X, ShAmtOp);
1800 Builder.Insert(NewShift);
1804 if (NoTruncOrTruncIsOneUse &&
1806 *ShAmt == BitWidth - 1) {
1807 Value *ShAmtOp = cast<Instruction>(Op1Wide)->getOperand(1);
1808 Instruction *NewShift = BinaryOperator::CreateLShr(X, ShAmtOp);
1812 Builder.Insert(NewShift);
1816 if (!HadTrunc && Op1->hasOneUse()) {
1822 cast<SelectInst>(Op1)->swapValues();
1824 return replaceInstUsesWith(I, Op1);
1833 if ((*Op0C | RHSKnown.
Zero).isAllOnesValue())
1834 return BinaryOperator::CreateXor(Op1, Op0);
1854 return BinaryOperator::CreateXor(A, B);
1871 return BinaryOperator::CreateAnd(A, B);
1887 return BinaryOperator::CreateAnd(
1888 Y, Builder.CreateNot(Op1, Op1->getName() +
".not"));
1906 Builder.CreateAnd(Op1, Builder.CreateNot(C)));
1921 auto SinkSubIntoSelect =
1924 Value *Cond, *TrueVal, *FalseVal;
1928 if (OtherHandOfSub != TrueVal && OtherHandOfSub != FalseVal)
1933 bool OtherHandOfSubIsTrueVal = OtherHandOfSub == TrueVal;
1934 Value *NewSub = SubBuilder(OtherHandOfSubIsTrueVal ? FalseVal : TrueVal);
1938 OtherHandOfSubIsTrueVal ? NewSub : Zero);
1945 [Builder = &Builder, Op1](
Value *OtherHandOfSelect) {
1946 return Builder->CreateSub(OtherHandOfSelect,
1952 [Builder = &Builder, Op0](
Value *OtherHandOfSelect) {
1953 return Builder->CreateSub(Op0,
1959 if (Op1->hasOneUse()) {
1960 Value *X =
nullptr, *Y =
nullptr, *Z =
nullptr;
1966 Builder.CreateSub(Z, Y, Op1->
getName()));
1970 return BinaryOperator::CreateAnd(Op0,
1971 Builder.CreateNot(Y, Y->
getName() +
".not"));
1981 BO->
setIsExact(cast<BinaryOperator>(Op1)->isExact());
1988 if (
Value *XNeg = dyn_castNegVal(X))
1989 return BinaryOperator::CreateShl(XNeg, Y);
2031 Value *LHS, *RHS, *A;
2032 Value *NotA = Op0, *MinMax = Op1;
2049 Value *Not = Builder.CreateNot(MinMax);
2051 return BinaryOperator::CreateSub(Not, A);
2053 return BinaryOperator::CreateSub(A, Not);
2060 Value *LHSOp, *RHSOp;
2063 if (
Value *Res = OptimizePointerDifference(LHSOp, RHSOp, I.
getType(),
2065 return replaceInstUsesWith(I, Res);
2070 if (
Value *Res = OptimizePointerDifference(LHSOp, RHSOp, I.
getType(),
2072 return replaceInstUsesWith(I, Res);
2096 canonicalizeCondSignextOfHighBitExtractToSignextHighBitExtract(I))
2102 bool Changed =
false;
2112 return Changed ? &
I :
nullptr;
2158 SQ.getWithInstruction(&I)))
2159 return replaceInstUsesWith(I, V);
2180 SQ.getWithInstruction(&I)))
2181 return replaceInstUsesWith(I, V);
2209 Value *NewSub = Builder.CreateFSubFMF(Y, X, &I);
2214 if (isa<Constant>(Op0))
2243 Value *FMul = Builder.CreateFMulFMF(X, Y, &I);
2250 Value *FDiv = Builder.CreateFDivFMF(X, Y, &I);
2255 if (
Value *V = SimplifySelectsFeedingBinaryOp(I, Op0, Op1))
2256 return replaceInstUsesWith(I, V);
2287 return replaceInstUsesWith(I, V);
MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty > m_UMin(const LHS &L, const RHS &R)
cst_pred_ty< icmp_pred_with_threshold > m_SpecificInt_ICMP(ICmpInst::Predicate Predicate, const APInt &Threshold)
Match an integer or vector with every element comparing 'pred' (eg/ne/...) to Threshold.
Value * EmitGEPOffset(IRBuilderTy *Builder, const DataLayout &DL, User *GEP, bool NoAssumptions=false)
Given a getelementptr instruction/constantexpr, emit the code necessary to compute the offset from th...
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, OptimizationRemarkEmitter *ORE=nullptr, bool UseInstrInfo=true)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
std::string & operator+=(std::string &buffer, StringRef string)
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
bool isSignMask() const
Check if the APInt's value is returned by getSignMask.
static bool isConstant(const MachineInstr &MI)
bool hasNoSignedZeros() const
Determine whether the no-signed-zeros flag is set.
APInt sext(unsigned width) const
Sign extend to a new width.
ThreeOps_match< Cond, LHS, RHS, Instruction::Select > m_Select(const Cond &C, const LHS &L, const RHS &R)
Matches SelectInst.
BinaryOp_match< LHS, RHS, Instruction::Sub > m_Sub(const LHS &L, const RHS &R)
is_zero m_Zero()
Match any null constant or a vector with all elements equal to 0.
DiagnosticInfoOptimizationBase::Argument NV
static BinaryOperator * CreateNot(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
This class represents lattice values for constants.
BinaryOps getOpcode() const
BinaryOp_match< LHS, RHS, Instruction::Xor, true > m_c_Xor(const LHS &L, const RHS &R)
Matches an Xor with LHS and RHS in either order.
static bool MatchRem(Value *E, Value *&Op, APInt &C, bool &IsSigned)
BinaryOp_match< LHS, RHS, Instruction::FDiv > m_FDiv(const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::SRem > m_SRem(const LHS &L, const RHS &R)
Value * OptimizePointerDifference(Value *LHS, Value *RHS, Type *Ty, bool isNUW)
Optimize pointer differences into the same array into a size.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
BinaryOp_match< LHS, RHS, Instruction::FAdd, true > m_c_FAdd(const LHS &L, const RHS &R)
Matches FAdd with LHS and RHS in either order.
This class represents zero extension of integer types.
Value * CreateNUWAdd(Value *LHS, Value *RHS, const Twine &Name="")
BinaryOp_match< LHS, RHS, Instruction::Mul > m_Mul(const LHS &L, const RHS &R)
class_match< Constant > m_Constant()
Match an arbitrary Constant and ignore it.
const Value * getTrueValue() const
BinaryOp_match< LHS, RHS, Instruction::AShr > m_AShr(const LHS &L, const RHS &R)
static bool MatchDiv(Value *E, Value *&Op, APInt &C, bool IsSigned)
Instruction * visitFSub(BinaryOperator &I)
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=nullptr, Instruction *MDFrom=nullptr)
APInt trunc(unsigned width) const
Truncate to new width.
Value * CreateSExt(Value *V, Type *DestTy, const Twine &Name="")
const fltSemantics & getSemantics() const
BinaryOp_match< LHS, RHS, Instruction::FSub > m_FSub(const LHS &L, const RHS &R)
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
bool isVectorTy() const
True if this is an instance of VectorType.
void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
AnyBinaryOp_match< LHS, RHS, true > m_c_BinOp(const LHS &L, const RHS &R)
Matches a BinaryOperator with LHS and RHS in either order.
bool hasNoSignedWrap() const
Determine whether the no signed wrap flag is set.
static bool isFreeToInvert(Value *V, bool WillInvertAllUses)
Return true if the specified value is free to invert (apply ~ to).
Value * CreateFNegFMF(Value *V, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
cst_pred_ty< is_zero_int > m_ZeroInt()
Match an integer 0 or a vector with all elements equal to 0.
unsigned getBitWidth() const
Return the number of bits in the APInt.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
unsigned countTrailingZeros() const
Count the number of trailing zero bits.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
bool match(Val *V, const Pattern &P)
match_combine_or< CastClass_match< OpTy, Instruction::ZExt >, OpTy > m_ZExtOrSelf(const OpTy &Op)
static Instruction * foldToUnsignedSaturatedAdd(BinaryOperator &I)
BinaryOp_match< LHS, RHS, Instruction::Xor > m_Xor(const LHS &L, const RHS &R)
This class represents the LLVM 'select' instruction.
roundingMode
IEEE-754R 4.3: Rounding-direction attributes.
CastClass_match< OpTy, Instruction::Trunc > m_Trunc(const OpTy &Op)
Matches Trunc.
static Constant * AddOne(Constant *C)
Add one to a Constant.
BinaryOp_match< LHS, RHS, Instruction::FMul, true > m_c_FMul(const LHS &L, const RHS &R)
Matches FMul with LHS and RHS in either order.
Value * CreateFAddFMF(Value *L, Value *R, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
bool MaskedValueIsZero(const Value *V, const APInt &Mask, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Return true if 'V & Mask' is known to be zero.
static Constant * getSExt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
This file implements a class to represent arbitrary precision integral constant values and operations...
BinaryOp_match< LHS, RHS, Instruction::Add > m_Add(const LHS &L, const RHS &R)
Value * SimplifyFNegInst(Value *Op, FastMathFlags FMF, const SimplifyQuery &Q)
Given operand for an FNeg, fold the result or return null.
static Constant * getZExt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWAdd(const LHS &L, const RHS &R)
Value * SimplifyFAddInst(Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q)
Given operands for an FAdd, fold the result or return null.
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag...
Type * getType() const
All values are typed, get the type of this value.
apfloat_match m_APFloat(const APFloat *&Res)
Match a ConstantFP or splatted ConstantVector, binding the specified pointer to the contained APFloat...
CastClass_match< OpTy, Instruction::FPExt > m_FPExt(const OpTy &Op)
Matches FPExt.
static BinaryOperator * CreateFMulFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
CastClass_match< OpTy, Instruction::ZExt > m_ZExt(const OpTy &Op)
Matches ZExt.
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
CastClass_match< OpTy, Instruction::FPTrunc > m_FPTrunc(const OpTy &Op)
Matches FPTrunc.
bool isNotOneValue() const
Return true if the value is not the one value, or, for vectors, does not contain one value elements...
class_match< ConstantInt > m_ConstantInt()
Match an arbitrary ConstantInt and ignore it.
const APInt & getValue() const
Return the constant as an APInt value reference.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
cstfp_pred_ty< is_pos_zero_fp > m_PosZeroFP()
Match a floating-point positive zero.
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="")
match_combine_or< CastClass_match< OpTy, Instruction::Trunc >, OpTy > m_TruncOrSelf(const OpTy &Op)
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
static BinaryOperator * CreateAdd(Value *S1, Value *S2, const Twine &Name, Instruction *InsertBefore, Value *FlagsOp)
Value * getOperand(unsigned i) const
bool CannotBeNegativeZero(const Value *V, const TargetLibraryInfo *TLI, unsigned Depth=0)
Return true if we can prove that the specified FP value is never equal to -0.0.
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Get a value with high bits set.
MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty, true > m_c_UMin(const LHS &L, const RHS &R)
Matches a UMin with LHS and RHS in either order.
OneUse_match< T > m_OneUse(const T &SubPattern)
bool isNegative() const
Determine sign of this APInt.
static Constant * getFNeg(Constant *C)
BinaryOp_match< LHS, RHS, Instruction::LShr > m_LShr(const LHS &L, const RHS &R)
bool hasNUsesOrMore(unsigned N) const
Return true if this value has N users or more.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
apint_match m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt...
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
BinaryOp_match< LHS, RHS, Instruction::SDiv > m_SDiv(const LHS &L, const RHS &R)
BinaryOp_match< LHS, RHS, Instruction::Add, true > m_c_Add(const LHS &L, const RHS &R)
Matches a Add with LHS and RHS in either order.
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)
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isSignBitCheck(ICmpInst::Predicate Pred, const APInt &RHS, bool &TrueIfSigned)
Given an exploded icmp instruction, return true if the comparison only checks the sign bit...
BinaryOp_match< LHS, RHS, Instruction::And, true > m_c_And(const LHS &L, const RHS &R)
Matches an And with LHS and RHS in either order.
ConstantFP - Floating Point Values [float, double].
bool isMask(unsigned numBits) const
bool isOneValue() const
Determine if this is a value of 1.
cst_pred_ty< is_all_ones > m_AllOnes()
Match an integer or vector with all bits set.
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
Value * SimplifyAddInst(Value *LHS, Value *RHS, bool isNSW, bool isNUW, const SimplifyQuery &Q)
Given operands for an Add, fold the result or return null.
bool isMinSignedValue() const
Determine if this is the smallest signed value.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
BinaryOp_match< LHS, RHS, Instruction::Shl > m_Shl(const LHS &L, const RHS &R)
static Instruction * foldFNegIntoConstant(Instruction &I)
This eliminates floating-point negation in either 'fneg(X)' or 'fsub(-0.0, X)' form by combining into...
Value * CreateFSubFMF(Value *L, Value *R, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
opStatus multiply(const APFloat &RHS, roundingMode RM)
class_match< BinaryOperator > m_BinOp()
Match an arbitrary binary operation and ignore it.
static Instruction * factorizeFAddFSub(BinaryOperator &I, InstCombiner::BuilderTy &Builder)
Factor a common operand out of fadd/fsub of fmul/fdiv.
Instruction * visitFAdd(BinaryOperator &I)
const Value * getCondition() const
static Constant * getAllOnesValue(Type *Ty)
NUW NUW NUW NUW Exact static Exact BinaryOperator * CreateNeg(Value *Op, const Twine &Name="", Instruction *InsertBefore=nullptr)
Helper functions to construct and inspect unary operations (NEG and NOT) via binary operators SUB and...
static CastInst * CreateZExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a ZExt or BitCast cast instruction.
deferredval_ty< Value > m_Deferred(Value *const &V)
A commutative-friendly version of m_Specific().
Instruction * visitFNeg(UnaryOperator &I)
const APFloat & getValueAPF() const
CastClass_match< OpTy, Instruction::SExt > m_SExt(const OpTy &Op)
Matches SExt.
static Constant * getSIToFP(Constant *C, Type *Ty, bool OnlyIfReduced=false)
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag...
BinaryOp_match< LHS, RHS, Instruction::Or, true > m_c_Or(const LHS &L, const RHS &R)
Matches an Or with LHS and RHS in either order.
This is the shared class of boolean and integer constants.
SelectPatternFlavor Flavor
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
bool containsUndefElement() const
Return true if this is a vector constant that includes any undefined elements.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
SelectPatternFlavor
Specific patterns of select instructions we can match.
BinaryOp_match< LHS, RHS, Instruction::URem > m_URem(const LHS &L, const RHS &R)
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
BinaryOp_match< LHS, RHS, Instruction::UDiv > m_UDiv(const LHS &L, const RHS &R)
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.
BinaryOp_match< LHS, RHS, Instruction::Mul, true > m_c_Mul(const LHS &L, const RHS &R)
Matches a Mul with LHS and RHS in either order.
static Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
BinaryOp_match< LHS, RHS, Instruction::FMul > m_FMul(const LHS &L, const RHS &R)
static unsigned int semanticsPrecision(const fltSemantics &)
OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoSignedWrap > m_NSWAdd(const LHS &L, const RHS &R)
void setOperand(unsigned i, Value *Val)
unsigned logBase2() const
BinaryOp_match< cst_pred_ty< is_zero_int >, ValTy, Instruction::Sub > m_Neg(const ValTy &V)
Matches a 'Neg' as 'sub 0, V'.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Class for arbitrary precision integers.
static Instruction * factorizeLerp(BinaryOperator &I, InstCombiner::BuilderTy &Builder)
Eliminate an op from a linear interpolation (lerp) pattern.
Value * SimplifyFSubInst(Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q)
Given operands for an FSub, fold the result or return null.
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
bool sge(const APInt &RHS) const
Signed greater or equal comparison.
CastClass_match< OpTy, Instruction::PtrToInt > m_PtrToInt(const OpTy &Op)
Matches PtrToInt.
A suitably aligned and sized character array member which can hold elements of any type...
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
const Value * getFalseValue() const
static BinaryOperator * CreateFDivFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
static BinaryOperator * CreateFNegFMF(Value *Op, Instruction *FMFSource, const Twine &Name="")
static Constant * getFSub(Constant *C1, Constant *C2)
static Instruction * canonicalizeLowbitMask(BinaryOperator &I, InstCombiner::BuilderTy &Builder)
Fold (1 << NBits) - 1 Into: ~(-(1 << NBits)) Because a 'not' is better for bit-tracking analysis and ...
match_combine_or< CastClass_match< OpTy, Instruction::SExt >, OpTy > m_SExtOrSelf(const OpTy &Op)
static Constant * getNeg(Constant *C, bool HasNUW=false, bool HasNSW=false)
specific_fpval m_FPOne()
Match a float 1.0 or vector with all elements equal to 1.0.
static Value * checkForNegativeOperand(BinaryOperator &I, InstCombiner::BuilderTy &Builder)
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 ...
opStatus add(const APFloat &RHS, roundingMode RM)
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
FNeg_match< OpTy > m_FNeg(const OpTy &X)
Match 'fneg X' as 'fsub -0.0, X'.
static bool MulWillOverflow(APInt &C0, APInt &C1, bool IsSigned)
unsigned getIntegerBitWidth() const
Instruction * visitAdd(BinaryOperator &I)
static CastInst * CreateTruncOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a Trunc or BitCast cast instruction.
static bool isMinOrMax(SelectPatternFlavor SPF)
When implementing this min/max pattern as fcmp; select, does the fcmp have to be ordered?
bool isZero() const
Return true if the value is positive or negative zero.
StringRef getName() const
Return a constant reference to the value's name.
APInt smul_ov(const APInt &RHS, bool &Overflow) const
bool haveNoCommonBitsSet(const Value *LHS, const Value *RHS, const DataLayout &DL, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Return true if LHS and RHS have no common bits set.
static Constant * getZeroValueForNegation(Type *Ty)
Floating point negation must be implemented with f(x) = -0.0 - x.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static Instruction * hoistFNegAboveFMulFDiv(Instruction &I, InstCombiner::BuilderTy &Builder)
static BinaryOperator * CreateFAddFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
bool hasNoUnsignedWrap() const
Determine whether the no unsigned wrap flag is set.
static bool MatchMul(Value *E, Value *&Op, APInt &C)
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
APInt umul_ov(const APInt &RHS, bool &Overflow) const
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag...
static CastInst * CreateSExtOrBitCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a SExt or BitCast cast instruction.
This class represents a cast from signed integer to floating point.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Value * CreateFMulFMF(Value *L, Value *R, Instruction *FMFSource, const Twine &Name="")
Copy fast-math-flags from an instruction rather than using the builder's default FMF.
LLVM Value Representation.
This file provides internal interfaces used to implement the InstCombine.
SelectPatternResult matchSelectPattern(Value *V, Value *&LHS, Value *&RHS, Instruction::CastOps *CastOp=nullptr, unsigned Depth=0)
Pattern match integer [SU]MIN, [SU]MAX and ABS idioms, returning the kind and providing the out param...
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
bool hasAllowReassoc() const
Determine whether the allow-reassociation flag is set.
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
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.
static Constant * getFPToSI(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Value * SimplifySubInst(Value *LHS, Value *RHS, bool isNSW, bool isNUW, const SimplifyQuery &Q)
Given operands for a Sub, fold the result or return null.
match_combine_and< LTy, RTy > m_CombineAnd(const LTy &L, const RTy &R)
Combine two pattern matchers matching L && R.
bool isNotMinSignedValue() const
Return true if the value is not the smallest signed value, or, for vectors, does not contain smallest...
bool hasOneUse() const
Return true if there is exactly one user of this value.
unsigned countNonConstantIndices() const
static BinaryOperator * CreateFSubFMF(Value *V1, Value *V2, Instruction *FMFSource, const Twine &Name="")
Instruction * visitSub(BinaryOperator &I)
static Constant * SubOne(Constant *C)
Subtract one from a Constant.
bind_ty< Instruction > m_Instruction(Instruction *&I)
Match an instruction, capturing it if we match.
static Instruction * foldNoWrapAdd(BinaryOperator &Add, InstCombiner::BuilderTy &Builder)
Wrapping flags may allow combining constants separated by an extend.
BinaryOp_match< ValTy, cst_pred_ty< is_all_ones >, Instruction::Xor, true > m_Not(const ValTy &V)
Matches a 'Not' as 'xor V, -1' or 'xor -1, V'.
bool isNullValue() const
Determine if all bits are clear.
Instruction * canonicalizeCondSignextOfHighBitExtractToSignextHighBitExtract(BinaryOperator &I)
CmpClass_match< LHS, RHS, ICmpInst, ICmpInst::Predicate > m_ICmp(ICmpInst::Predicate &Pred, const LHS &L, const RHS &R)
const fltSemantics & getFltSemantics() const
static Constant * getXor(Constant *C1, Constant *C2)