LLVM  14.0.0git
ConstantRange.cpp
Go to the documentation of this file.
1 //===- ConstantRange.cpp - ConstantRange implementation -------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Represent a range of possible values that may occur when the program is run
10 // for an integral value. This keeps track of a lower and upper bound for the
11 // constant, which MAY wrap around the end of the numeric range. To do this, it
12 // keeps track of a [lower, upper) bound, which specifies an interval just like
13 // STL iterators. When used with boolean values, the following are important
14 // ranges (other integral ranges use min/max values for special range values):
15 //
16 // [F, F) = {} = Empty set
17 // [T, F) = {T}
18 // [F, T) = {F}
19 // [T, T) = {F, T} = Full set
20 //
21 //===----------------------------------------------------------------------===//
22 
23 #include "llvm/ADT/APInt.h"
24 #include "llvm/Config/llvm-config.h"
25 #include "llvm/IR/ConstantRange.h"
26 #include "llvm/IR/Constants.h"
27 #include "llvm/IR/InstrTypes.h"
28 #include "llvm/IR/Instruction.h"
29 #include "llvm/IR/Intrinsics.h"
30 #include "llvm/IR/Metadata.h"
31 #include "llvm/IR/Operator.h"
32 #include "llvm/Support/Compiler.h"
33 #include "llvm/Support/Debug.h"
35 #include "llvm/Support/KnownBits.h"
37 #include <algorithm>
38 #include <cassert>
39 #include <cstdint>
40 
41 using namespace llvm;
42 
45  Upper(Lower) {}
46 
48  : Lower(std::move(V)), Upper(Lower + 1) {}
49 
51  : Lower(std::move(L)), Upper(std::move(U)) {
52  assert(Lower.getBitWidth() == Upper.getBitWidth() &&
53  "ConstantRange with unequal bit widths");
54  assert((Lower != Upper || (Lower.isMaxValue() || Lower.isMinValue())) &&
55  "Lower == Upper, but they aren't min or max value!");
56 }
57 
59  bool IsSigned) {
60  assert(!Known.hasConflict() && "Expected valid KnownBits");
61 
62  if (Known.isUnknown())
63  return getFull(Known.getBitWidth());
64 
65  // For unsigned ranges, or signed ranges with known sign bit, create a simple
66  // range between the smallest and largest possible value.
67  if (!IsSigned || Known.isNegative() || Known.isNonNegative())
68  return ConstantRange(Known.getMinValue(), Known.getMaxValue() + 1);
69 
70  // If we don't know the sign bit, pick the lower bound as a negative number
71  // and the upper bound as a non-negative one.
72  APInt Lower = Known.getMinValue(), Upper = Known.getMaxValue();
73  Lower.setSignBit();
74  Upper.clearSignBit();
75  return ConstantRange(Lower, Upper + 1);
76 }
77 
79  const ConstantRange &CR) {
80  if (CR.isEmptySet())
81  return CR;
82 
83  uint32_t W = CR.getBitWidth();
84  switch (Pred) {
85  default:
86  llvm_unreachable("Invalid ICmp predicate to makeAllowedICmpRegion()");
87  case CmpInst::ICMP_EQ:
88  return CR;
89  case CmpInst::ICMP_NE:
90  if (CR.isSingleElement())
91  return ConstantRange(CR.getUpper(), CR.getLower());
92  return getFull(W);
93  case CmpInst::ICMP_ULT: {
95  if (UMax.isMinValue())
96  return getEmpty(W);
98  }
99  case CmpInst::ICMP_SLT: {
100  APInt SMax(CR.getSignedMax());
101  if (SMax.isMinSignedValue())
102  return getEmpty(W);
104  }
105  case CmpInst::ICMP_ULE:
106  return getNonEmpty(APInt::getMinValue(W), CR.getUnsignedMax() + 1);
107  case CmpInst::ICMP_SLE:
109  case CmpInst::ICMP_UGT: {
110  APInt UMin(CR.getUnsignedMin());
111  if (UMin.isMaxValue())
112  return getEmpty(W);
114  }
115  case CmpInst::ICMP_SGT: {
116  APInt SMin(CR.getSignedMin());
117  if (SMin.isMaxSignedValue())
118  return getEmpty(W);
120  }
121  case CmpInst::ICMP_UGE:
123  case CmpInst::ICMP_SGE:
125  }
126 }
127 
129  const ConstantRange &CR) {
130  // Follows from De-Morgan's laws:
131  //
132  // ~(~A union ~B) == A intersect B.
133  //
135  .inverse();
136 }
137 
139  const APInt &C) {
140  // Computes the exact range that is equal to both the constant ranges returned
141  // by makeAllowedICmpRegion and makeSatisfyingICmpRegion. This is always true
142  // when RHS is a singleton such as an APInt and so the assert is valid.
143  // However for non-singleton RHS, for example ult [2,5) makeAllowedICmpRegion
144  // returns [0,4) but makeSatisfyICmpRegion returns [0,2).
145  //
147  return makeAllowedICmpRegion(Pred, C);
148 }
149 
151  APInt &RHS) const {
152  bool Success = false;
153 
154  if (isFullSet() || isEmptySet()) {
156  RHS = APInt(getBitWidth(), 0);
157  Success = true;
158  } else if (auto *OnlyElt = getSingleElement()) {
159  Pred = CmpInst::ICMP_EQ;
160  RHS = *OnlyElt;
161  Success = true;
162  } else if (auto *OnlyMissingElt = getSingleMissingElement()) {
163  Pred = CmpInst::ICMP_NE;
164  RHS = *OnlyMissingElt;
165  Success = true;
166  } else if (getLower().isMinSignedValue() || getLower().isMinValue()) {
167  Pred =
169  RHS = getUpper();
170  Success = true;
171  } else if (getUpper().isMinSignedValue() || getUpper().isMinValue()) {
172  Pred =
174  RHS = getLower();
175  Success = true;
176  }
177 
178  assert((!Success || ConstantRange::makeExactICmpRegion(Pred, RHS) == *this) &&
179  "Bad result!");
180 
181  return Success;
182 }
183 
185  const ConstantRange &Other) const {
186  return makeSatisfyingICmpRegion(Pred, Other).contains(*this);
187 }
188 
189 /// Exact mul nuw region for single element RHS.
191  unsigned BitWidth = V.getBitWidth();
192  if (V == 0)
193  return ConstantRange::getFull(V.getBitWidth());
194 
199  APInt::Rounding::DOWN) + 1);
200 }
201 
202 /// Exact mul nsw region for single element RHS.
204  // Handle special case for 0, -1 and 1. See the last for reason why we
205  // specialize -1 and 1.
206  unsigned BitWidth = V.getBitWidth();
207  if (V == 0 || V.isOne())
208  return ConstantRange::getFull(BitWidth);
209 
212  // e.g. Returning [-127, 127], represented as [-127, -128).
213  if (V.isAllOnes())
214  return ConstantRange(-MaxValue, MinValue);
215 
216  APInt Lower, Upper;
217  if (V.isNegative()) {
220  } else {
223  }
224  // ConstantRange ctor take a half inclusive interval [Lower, Upper + 1).
225  // Upper + 1 is guaranteed not to overflow, because |divisor| > 1. 0, -1,
226  // and 1 are already handled as special cases.
227  return ConstantRange(Lower, Upper + 1);
228 }
229 
232  const ConstantRange &Other,
233  unsigned NoWrapKind) {
234  using OBO = OverflowingBinaryOperator;
235 
236  assert(Instruction::isBinaryOp(BinOp) && "Binary operators only!");
237 
238  assert((NoWrapKind == OBO::NoSignedWrap ||
239  NoWrapKind == OBO::NoUnsignedWrap) &&
240  "NoWrapKind invalid!");
241 
242  bool Unsigned = NoWrapKind == OBO::NoUnsignedWrap;
243  unsigned BitWidth = Other.getBitWidth();
244 
245  switch (BinOp) {
246  default:
247  llvm_unreachable("Unsupported binary op");
248 
249  case Instruction::Add: {
250  if (Unsigned)
251  return getNonEmpty(APInt::getZero(BitWidth), -Other.getUnsignedMax());
252 
253  APInt SignedMinVal = APInt::getSignedMinValue(BitWidth);
254  APInt SMin = Other.getSignedMin(), SMax = Other.getSignedMax();
255  return getNonEmpty(
256  SMin.isNegative() ? SignedMinVal - SMin : SignedMinVal,
257  SMax.isStrictlyPositive() ? SignedMinVal - SMax : SignedMinVal);
258  }
259 
260  case Instruction::Sub: {
261  if (Unsigned)
262  return getNonEmpty(Other.getUnsignedMax(), APInt::getMinValue(BitWidth));
263 
264  APInt SignedMinVal = APInt::getSignedMinValue(BitWidth);
265  APInt SMin = Other.getSignedMin(), SMax = Other.getSignedMax();
266  return getNonEmpty(
267  SMax.isStrictlyPositive() ? SignedMinVal + SMax : SignedMinVal,
268  SMin.isNegative() ? SignedMinVal + SMin : SignedMinVal);
269  }
270 
271  case Instruction::Mul:
272  if (Unsigned)
273  return makeExactMulNUWRegion(Other.getUnsignedMax());
274 
275  return makeExactMulNSWRegion(Other.getSignedMin())
276  .intersectWith(makeExactMulNSWRegion(Other.getSignedMax()));
277 
278  case Instruction::Shl: {
279  // For given range of shift amounts, if we ignore all illegal shift amounts
280  // (that always produce poison), what shift amount range is left?
281  ConstantRange ShAmt = Other.intersectWith(
282  ConstantRange(APInt(BitWidth, 0), APInt(BitWidth, (BitWidth - 1) + 1)));
283  if (ShAmt.isEmptySet()) {
284  // If the entire range of shift amounts is already poison-producing,
285  // then we can freely add more poison-producing flags ontop of that.
286  return getFull(BitWidth);
287  }
288  // There are some legal shift amounts, we can compute conservatively-correct
289  // range of no-wrap inputs. Note that by now we have clamped the ShAmtUMax
290  // to be at most bitwidth-1, which results in most conservative range.
291  APInt ShAmtUMax = ShAmt.getUnsignedMax();
292  if (Unsigned)
294  APInt::getMaxValue(BitWidth).lshr(ShAmtUMax) + 1);
296  APInt::getSignedMaxValue(BitWidth).ashr(ShAmtUMax) + 1);
297  }
298  }
299 }
300 
302  const APInt &Other,
303  unsigned NoWrapKind) {
304  // makeGuaranteedNoWrapRegion() is exact for single-element ranges, as
305  // "for all" and "for any" coincide in this case.
306  return makeGuaranteedNoWrapRegion(BinOp, ConstantRange(Other), NoWrapKind);
307 }
308 
310  return Lower == Upper && Lower.isMaxValue();
311 }
312 
314  return Lower == Upper && Lower.isMinValue();
315 }
316 
318  return Lower.ugt(Upper) && !Upper.isZero();
319 }
320 
322  return Lower.ugt(Upper);
323 }
324 
326  return Lower.sgt(Upper) && !Upper.isMinSignedValue();
327 }
328 
330  return Lower.sgt(Upper);
331 }
332 
333 bool
335  assert(getBitWidth() == Other.getBitWidth());
336  if (isFullSet())
337  return false;
338  if (Other.isFullSet())
339  return true;
340  return (Upper - Lower).ult(Other.Upper - Other.Lower);
341 }
342 
343 bool
345  assert(MaxSize && "MaxSize can't be 0.");
346  // If this a full set, we need special handling to avoid needing an extra bit
347  // to represent the size.
348  if (isFullSet())
349  return APInt::getMaxValue(getBitWidth()).ugt(MaxSize - 1);
350 
351  return (Upper - Lower).ugt(MaxSize);
352 }
353 
355  // Empty set is all negative, full set is not.
356  if (isEmptySet())
357  return true;
358  if (isFullSet())
359  return false;
360 
361  return !isUpperSignWrapped() && !Upper.isStrictlyPositive();
362 }
363 
365  // Empty and full set are automatically treated correctly.
366  return !isSignWrappedSet() && Lower.isNonNegative();
367 }
368 
370  if (isFullSet() || isUpperWrapped())
372  return getUpper() - 1;
373 }
374 
376  if (isFullSet() || isWrappedSet())
378  return getLower();
379 }
380 
382  if (isFullSet() || isUpperSignWrapped())
384  return getUpper() - 1;
385 }
386 
388  if (isFullSet() || isSignWrappedSet())
390  return getLower();
391 }
392 
393 bool ConstantRange::contains(const APInt &V) const {
394  if (Lower == Upper)
395  return isFullSet();
396 
397  if (!isUpperWrapped())
398  return Lower.ule(V) && V.ult(Upper);
399  return Lower.ule(V) || V.ult(Upper);
400 }
401 
403  if (isFullSet() || Other.isEmptySet()) return true;
404  if (isEmptySet() || Other.isFullSet()) return false;
405 
406  if (!isUpperWrapped()) {
407  if (Other.isUpperWrapped())
408  return false;
409 
410  return Lower.ule(Other.getLower()) && Other.getUpper().ule(Upper);
411  }
412 
413  if (!Other.isUpperWrapped())
414  return Other.getUpper().ule(Upper) ||
415  Lower.ule(Other.getLower());
416 
417  return Other.getUpper().ule(Upper) && Lower.ule(Other.getLower());
418 }
419 
421  if (isEmptySet())
422  return 0;
423 
424  return getUnsignedMax().getActiveBits();
425 }
426 
428  if (isEmptySet())
429  return 0;
430 
433 }
434 
436  assert(Val.getBitWidth() == getBitWidth() && "Wrong bit width");
437  // If the set is empty or full, don't modify the endpoints.
438  if (Lower == Upper)
439  return *this;
440  return ConstantRange(Lower - Val, Upper - Val);
441 }
442 
444  return intersectWith(CR.inverse());
445 }
446 
448  const ConstantRange &CR1, const ConstantRange &CR2,
450  if (Type == ConstantRange::Unsigned) {
451  if (!CR1.isWrappedSet() && CR2.isWrappedSet())
452  return CR1;
453  if (CR1.isWrappedSet() && !CR2.isWrappedSet())
454  return CR2;
455  } else if (Type == ConstantRange::Signed) {
456  if (!CR1.isSignWrappedSet() && CR2.isSignWrappedSet())
457  return CR1;
458  if (CR1.isSignWrappedSet() && !CR2.isSignWrappedSet())
459  return CR2;
460  }
461 
462  if (CR1.isSizeStrictlySmallerThan(CR2))
463  return CR1;
464  return CR2;
465 }
466 
468  PreferredRangeType Type) const {
469  assert(getBitWidth() == CR.getBitWidth() &&
470  "ConstantRange types don't agree!");
471 
472  // Handle common cases.
473  if ( isEmptySet() || CR.isFullSet()) return *this;
474  if (CR.isEmptySet() || isFullSet()) return CR;
475 
476  if (!isUpperWrapped() && CR.isUpperWrapped())
477  return CR.intersectWith(*this, Type);
478 
479  if (!isUpperWrapped() && !CR.isUpperWrapped()) {
480  if (Lower.ult(CR.Lower)) {
481  // L---U : this
482  // L---U : CR
483  if (Upper.ule(CR.Lower))
484  return getEmpty();
485 
486  // L---U : this
487  // L---U : CR
488  if (Upper.ult(CR.Upper))
489  return ConstantRange(CR.Lower, Upper);
490 
491  // L-------U : this
492  // L---U : CR
493  return CR;
494  }
495  // L---U : this
496  // L-------U : CR
497  if (Upper.ult(CR.Upper))
498  return *this;
499 
500  // L-----U : this
501  // L-----U : CR
502  if (Lower.ult(CR.Upper))
503  return ConstantRange(Lower, CR.Upper);
504 
505  // L---U : this
506  // L---U : CR
507  return getEmpty();
508  }
509 
510  if (isUpperWrapped() && !CR.isUpperWrapped()) {
511  if (CR.Lower.ult(Upper)) {
512  // ------U L--- : this
513  // L--U : CR
514  if (CR.Upper.ult(Upper))
515  return CR;
516 
517  // ------U L--- : this
518  // L------U : CR
519  if (CR.Upper.ule(Lower))
520  return ConstantRange(CR.Lower, Upper);
521 
522  // ------U L--- : this
523  // L----------U : CR
524  return getPreferredRange(*this, CR, Type);
525  }
526  if (CR.Lower.ult(Lower)) {
527  // --U L---- : this
528  // L--U : CR
529  if (CR.Upper.ule(Lower))
530  return getEmpty();
531 
532  // --U L---- : this
533  // L------U : CR
534  return ConstantRange(Lower, CR.Upper);
535  }
536 
537  // --U L------ : this
538  // L--U : CR
539  return CR;
540  }
541 
542  if (CR.Upper.ult(Upper)) {
543  // ------U L-- : this
544  // --U L------ : CR
545  if (CR.Lower.ult(Upper))
546  return getPreferredRange(*this, CR, Type);
547 
548  // ----U L-- : this
549  // --U L---- : CR
550  if (CR.Lower.ult(Lower))
551  return ConstantRange(Lower, CR.Upper);
552 
553  // ----U L---- : this
554  // --U L-- : CR
555  return CR;
556  }
557  if (CR.Upper.ule(Lower)) {
558  // --U L-- : this
559  // ----U L---- : CR
560  if (CR.Lower.ult(Lower))
561  return *this;
562 
563  // --U L---- : this
564  // ----U L-- : CR
565  return ConstantRange(CR.Lower, Upper);
566  }
567 
568  // --U L------ : this
569  // ------U L-- : CR
570  return getPreferredRange(*this, CR, Type);
571 }
572 
574  PreferredRangeType Type) const {
575  assert(getBitWidth() == CR.getBitWidth() &&
576  "ConstantRange types don't agree!");
577 
578  if ( isFullSet() || CR.isEmptySet()) return *this;
579  if (CR.isFullSet() || isEmptySet()) return CR;
580 
581  if (!isUpperWrapped() && CR.isUpperWrapped())
582  return CR.unionWith(*this, Type);
583 
584  if (!isUpperWrapped() && !CR.isUpperWrapped()) {
585  // L---U and L---U : this
586  // L---U L---U : CR
587  // result in one of
588  // L---------U
589  // -----U L-----
590  if (CR.Upper.ult(Lower) || Upper.ult(CR.Lower))
591  return getPreferredRange(
592  ConstantRange(Lower, CR.Upper), ConstantRange(CR.Lower, Upper), Type);
593 
594  APInt L = CR.Lower.ult(Lower) ? CR.Lower : Lower;
595  APInt U = (CR.Upper - 1).ugt(Upper - 1) ? CR.Upper : Upper;
596 
597  if (L.isZero() && U.isZero())
598  return getFull();
599 
600  return ConstantRange(std::move(L), std::move(U));
601  }
602 
603  if (!CR.isUpperWrapped()) {
604  // ------U L----- and ------U L----- : this
605  // L--U L--U : CR
606  if (CR.Upper.ule(Upper) || CR.Lower.uge(Lower))
607  return *this;
608 
609  // ------U L----- : this
610  // L---------U : CR
611  if (CR.Lower.ule(Upper) && Lower.ule(CR.Upper))
612  return getFull();
613 
614  // ----U L---- : this
615  // L---U : CR
616  // results in one of
617  // ----------U L----
618  // ----U L----------
619  if (Upper.ult(CR.Lower) && CR.Upper.ult(Lower))
620  return getPreferredRange(
621  ConstantRange(Lower, CR.Upper), ConstantRange(CR.Lower, Upper), Type);
622 
623  // ----U L----- : this
624  // L----U : CR
625  if (Upper.ult(CR.Lower) && Lower.ule(CR.Upper))
626  return ConstantRange(CR.Lower, Upper);
627 
628  // ------U L---- : this
629  // L-----U : CR
630  assert(CR.Lower.ule(Upper) && CR.Upper.ult(Lower) &&
631  "ConstantRange::unionWith missed a case with one range wrapped");
632  return ConstantRange(Lower, CR.Upper);
633  }
634 
635  // ------U L---- and ------U L---- : this
636  // -U L----------- and ------------U L : CR
637  if (CR.Lower.ule(Upper) || Lower.ule(CR.Upper))
638  return getFull();
639 
640  APInt L = CR.Lower.ult(Lower) ? CR.Lower : Lower;
641  APInt U = CR.Upper.ugt(Upper) ? CR.Upper : Upper;
642 
643  return ConstantRange(std::move(L), std::move(U));
644 }
645 
647  uint32_t ResultBitWidth) const {
648  switch (CastOp) {
649  default:
650  llvm_unreachable("unsupported cast type");
651  case Instruction::Trunc:
652  return truncate(ResultBitWidth);
653  case Instruction::SExt:
654  return signExtend(ResultBitWidth);
655  case Instruction::ZExt:
656  return zeroExtend(ResultBitWidth);
657  case Instruction::BitCast:
658  return *this;
659  case Instruction::FPToUI:
660  case Instruction::FPToSI:
661  if (getBitWidth() == ResultBitWidth)
662  return *this;
663  else
664  return getFull(ResultBitWidth);
665  case Instruction::UIToFP: {
666  // TODO: use input range if available
667  auto BW = getBitWidth();
668  APInt Min = APInt::getMinValue(BW).zextOrSelf(ResultBitWidth);
669  APInt Max = APInt::getMaxValue(BW).zextOrSelf(ResultBitWidth);
670  return ConstantRange(std::move(Min), std::move(Max));
671  }
672  case Instruction::SIToFP: {
673  // TODO: use input range if available
674  auto BW = getBitWidth();
675  APInt SMin = APInt::getSignedMinValue(BW).sextOrSelf(ResultBitWidth);
676  APInt SMax = APInt::getSignedMaxValue(BW).sextOrSelf(ResultBitWidth);
678  }
679  case Instruction::FPTrunc:
680  case Instruction::FPExt:
681  case Instruction::IntToPtr:
682  case Instruction::PtrToInt:
683  case Instruction::AddrSpaceCast:
684  // Conservatively return getFull set.
685  return getFull(ResultBitWidth);
686  };
687 }
688 
690  if (isEmptySet()) return getEmpty(DstTySize);
691 
692  unsigned SrcTySize = getBitWidth();
693  assert(SrcTySize < DstTySize && "Not a value extension");
694  if (isFullSet() || isUpperWrapped()) {
695  // Change into [0, 1 << src bit width)
696  APInt LowerExt(DstTySize, 0);
697  if (!Upper) // special case: [X, 0) -- not really wrapping around
698  LowerExt = Lower.zext(DstTySize);
699  return ConstantRange(std::move(LowerExt),
700  APInt::getOneBitSet(DstTySize, SrcTySize));
701  }
702 
703  return ConstantRange(Lower.zext(DstTySize), Upper.zext(DstTySize));
704 }
705 
707  if (isEmptySet()) return getEmpty(DstTySize);
708 
709  unsigned SrcTySize = getBitWidth();
710  assert(SrcTySize < DstTySize && "Not a value extension");
711 
712  // special case: [X, INT_MIN) -- not really wrapping around
713  if (Upper.isMinSignedValue())
714  return ConstantRange(Lower.sext(DstTySize), Upper.zext(DstTySize));
715 
716  if (isFullSet() || isSignWrappedSet()) {
717  return ConstantRange(APInt::getHighBitsSet(DstTySize,DstTySize-SrcTySize+1),
718  APInt::getLowBitsSet(DstTySize, SrcTySize-1) + 1);
719  }
720 
721  return ConstantRange(Lower.sext(DstTySize), Upper.sext(DstTySize));
722 }
723 
725  assert(getBitWidth() > DstTySize && "Not a value truncation");
726  if (isEmptySet())
727  return getEmpty(DstTySize);
728  if (isFullSet())
729  return getFull(DstTySize);
730 
731  APInt LowerDiv(Lower), UpperDiv(Upper);
732  ConstantRange Union(DstTySize, /*isFullSet=*/false);
733 
734  // Analyze wrapped sets in their two parts: [0, Upper) \/ [Lower, MaxValue]
735  // We use the non-wrapped set code to analyze the [Lower, MaxValue) part, and
736  // then we do the union with [MaxValue, Upper)
737  if (isUpperWrapped()) {
738  // If Upper is greater than or equal to MaxValue(DstTy), it covers the whole
739  // truncated range.
740  if (Upper.getActiveBits() > DstTySize ||
741  Upper.countTrailingOnes() == DstTySize)
742  return getFull(DstTySize);
743 
744  Union = ConstantRange(APInt::getMaxValue(DstTySize),Upper.trunc(DstTySize));
745  UpperDiv.setAllBits();
746 
747  // Union covers the MaxValue case, so return if the remaining range is just
748  // MaxValue(DstTy).
749  if (LowerDiv == UpperDiv)
750  return Union;
751  }
752 
753  // Chop off the most significant bits that are past the destination bitwidth.
754  if (LowerDiv.getActiveBits() > DstTySize) {
755  // Mask to just the signficant bits and subtract from LowerDiv/UpperDiv.
756  APInt Adjust = LowerDiv & APInt::getBitsSetFrom(getBitWidth(), DstTySize);
757  LowerDiv -= Adjust;
758  UpperDiv -= Adjust;
759  }
760 
761  unsigned UpperDivWidth = UpperDiv.getActiveBits();
762  if (UpperDivWidth <= DstTySize)
763  return ConstantRange(LowerDiv.trunc(DstTySize),
764  UpperDiv.trunc(DstTySize)).unionWith(Union);
765 
766  // The truncated value wraps around. Check if we can do better than fullset.
767  if (UpperDivWidth == DstTySize + 1) {
768  // Clear the MSB so that UpperDiv wraps around.
769  UpperDiv.clearBit(DstTySize);
770  if (UpperDiv.ult(LowerDiv))
771  return ConstantRange(LowerDiv.trunc(DstTySize),
772  UpperDiv.trunc(DstTySize)).unionWith(Union);
773  }
774 
775  return getFull(DstTySize);
776 }
777 
779  unsigned SrcTySize = getBitWidth();
780  if (SrcTySize > DstTySize)
781  return truncate(DstTySize);
782  if (SrcTySize < DstTySize)
783  return zeroExtend(DstTySize);
784  return *this;
785 }
786 
788  unsigned SrcTySize = getBitWidth();
789  if (SrcTySize > DstTySize)
790  return truncate(DstTySize);
791  if (SrcTySize < DstTySize)
792  return signExtend(DstTySize);
793  return *this;
794 }
795 
797  const ConstantRange &Other) const {
798  assert(Instruction::isBinaryOp(BinOp) && "Binary operators only!");
799 
800  switch (BinOp) {
801  case Instruction::Add:
802  return add(Other);
803  case Instruction::Sub:
804  return sub(Other);
805  case Instruction::Mul:
806  return multiply(Other);
807  case Instruction::UDiv:
808  return udiv(Other);
809  case Instruction::SDiv:
810  return sdiv(Other);
811  case Instruction::URem:
812  return urem(Other);
813  case Instruction::SRem:
814  return srem(Other);
815  case Instruction::Shl:
816  return shl(Other);
817  case Instruction::LShr:
818  return lshr(Other);
819  case Instruction::AShr:
820  return ashr(Other);
821  case Instruction::And:
822  return binaryAnd(Other);
823  case Instruction::Or:
824  return binaryOr(Other);
825  case Instruction::Xor:
826  return binaryXor(Other);
827  // Note: floating point operations applied to abstract ranges are just
828  // ideal integer operations with a lossy representation
829  case Instruction::FAdd:
830  return add(Other);
831  case Instruction::FSub:
832  return sub(Other);
833  case Instruction::FMul:
834  return multiply(Other);
835  default:
836  // Conservatively return getFull set.
837  return getFull();
838  }
839 }
840 
842  const ConstantRange &Other,
843  unsigned NoWrapKind) const {
844  assert(Instruction::isBinaryOp(BinOp) && "Binary operators only!");
845 
846  switch (BinOp) {
847  case Instruction::Add:
848  return addWithNoWrap(Other, NoWrapKind);
849  case Instruction::Sub:
850  return subWithNoWrap(Other, NoWrapKind);
851  default:
852  // Don't know about this Overflowing Binary Operation.
853  // Conservatively fallback to plain binop handling.
854  return binaryOp(BinOp, Other);
855  }
856 }
857 
859  switch (IntrinsicID) {
860  case Intrinsic::uadd_sat:
861  case Intrinsic::usub_sat:
862  case Intrinsic::sadd_sat:
863  case Intrinsic::ssub_sat:
864  case Intrinsic::umin:
865  case Intrinsic::umax:
866  case Intrinsic::smin:
867  case Intrinsic::smax:
868  case Intrinsic::abs:
869  return true;
870  default:
871  return false;
872  }
873 }
874 
877  switch (IntrinsicID) {
878  case Intrinsic::uadd_sat:
879  return Ops[0].uadd_sat(Ops[1]);
880  case Intrinsic::usub_sat:
881  return Ops[0].usub_sat(Ops[1]);
882  case Intrinsic::sadd_sat:
883  return Ops[0].sadd_sat(Ops[1]);
884  case Intrinsic::ssub_sat:
885  return Ops[0].ssub_sat(Ops[1]);
886  case Intrinsic::umin:
887  return Ops[0].umin(Ops[1]);
888  case Intrinsic::umax:
889  return Ops[0].umax(Ops[1]);
890  case Intrinsic::smin:
891  return Ops[0].smin(Ops[1]);
892  case Intrinsic::smax:
893  return Ops[0].smax(Ops[1]);
894  case Intrinsic::abs: {
895  const APInt *IntMinIsPoison = Ops[1].getSingleElement();
896  assert(IntMinIsPoison && "Must be known (immarg)");
897  assert(IntMinIsPoison->getBitWidth() == 1 && "Must be boolean");
898  return Ops[0].abs(IntMinIsPoison->getBoolValue());
899  }
900  default:
901  assert(!isIntrinsicSupported(IntrinsicID) && "Shouldn't be supported");
902  llvm_unreachable("Unsupported intrinsic");
903  }
904 }
905 
908  if (isEmptySet() || Other.isEmptySet())
909  return getEmpty();
910  if (isFullSet() || Other.isFullSet())
911  return getFull();
912 
913  APInt NewLower = getLower() + Other.getLower();
914  APInt NewUpper = getUpper() + Other.getUpper() - 1;
915  if (NewLower == NewUpper)
916  return getFull();
917 
918  ConstantRange X = ConstantRange(std::move(NewLower), std::move(NewUpper));
919  if (X.isSizeStrictlySmallerThan(*this) ||
920  X.isSizeStrictlySmallerThan(Other))
921  // We've wrapped, therefore, full set.
922  return getFull();
923  return X;
924 }
925 
927  unsigned NoWrapKind,
928  PreferredRangeType RangeType) const {
929  // Calculate the range for "X + Y" which is guaranteed not to wrap(overflow).
930  // (X is from this, and Y is from Other)
931  if (isEmptySet() || Other.isEmptySet())
932  return getEmpty();
933  if (isFullSet() && Other.isFullSet())
934  return getFull();
935 
936  using OBO = OverflowingBinaryOperator;
937  ConstantRange Result = add(Other);
938 
939  // If an overflow happens for every value pair in these two constant ranges,
940  // we must return Empty set. In this case, we get that for free, because we
941  // get lucky that intersection of add() with uadd_sat()/sadd_sat() results
942  // in an empty set.
943 
944  if (NoWrapKind & OBO::NoSignedWrap)
945  Result = Result.intersectWith(sadd_sat(Other), RangeType);
946 
947  if (NoWrapKind & OBO::NoUnsignedWrap)
948  Result = Result.intersectWith(uadd_sat(Other), RangeType);
949 
950  return Result;
951 }
952 
955  if (isEmptySet() || Other.isEmptySet())
956  return getEmpty();
957  if (isFullSet() || Other.isFullSet())
958  return getFull();
959 
960  APInt NewLower = getLower() - Other.getUpper() + 1;
961  APInt NewUpper = getUpper() - Other.getLower();
962  if (NewLower == NewUpper)
963  return getFull();
964 
965  ConstantRange X = ConstantRange(std::move(NewLower), std::move(NewUpper));
966  if (X.isSizeStrictlySmallerThan(*this) ||
967  X.isSizeStrictlySmallerThan(Other))
968  // We've wrapped, therefore, full set.
969  return getFull();
970  return X;
971 }
972 
974  unsigned NoWrapKind,
975  PreferredRangeType RangeType) const {
976  // Calculate the range for "X - Y" which is guaranteed not to wrap(overflow).
977  // (X is from this, and Y is from Other)
978  if (isEmptySet() || Other.isEmptySet())
979  return getEmpty();
980  if (isFullSet() && Other.isFullSet())
981  return getFull();
982 
983  using OBO = OverflowingBinaryOperator;
984  ConstantRange Result = sub(Other);
985 
986  // If an overflow happens for every value pair in these two constant ranges,
987  // we must return Empty set. In signed case, we get that for free, because we
988  // get lucky that intersection of sub() with ssub_sat() results in an
989  // empty set. But for unsigned we must perform the overflow check manually.
990 
991  if (NoWrapKind & OBO::NoSignedWrap)
992  Result = Result.intersectWith(ssub_sat(Other), RangeType);
993 
994  if (NoWrapKind & OBO::NoUnsignedWrap) {
995  if (getUnsignedMax().ult(Other.getUnsignedMin()))
996  return getEmpty(); // Always overflows.
997  Result = Result.intersectWith(usub_sat(Other), RangeType);
998  }
999 
1000  return Result;
1001 }
1002 
1005  // TODO: If either operand is a single element and the multiply is known to
1006  // be non-wrapping, round the result min and max value to the appropriate
1007  // multiple of that element. If wrapping is possible, at least adjust the
1008  // range according to the greatest power-of-two factor of the single element.
1009 
1010  if (isEmptySet() || Other.isEmptySet())
1011  return getEmpty();
1012 
1013  // Multiplication is signedness-independent. However different ranges can be
1014  // obtained depending on how the input ranges are treated. These different
1015  // ranges are all conservatively correct, but one might be better than the
1016  // other. We calculate two ranges; one treating the inputs as unsigned
1017  // and the other signed, then return the smallest of these ranges.
1018 
1019  // Unsigned range first.
1020  APInt this_min = getUnsignedMin().zext(getBitWidth() * 2);
1021  APInt this_max = getUnsignedMax().zext(getBitWidth() * 2);
1022  APInt Other_min = Other.getUnsignedMin().zext(getBitWidth() * 2);
1023  APInt Other_max = Other.getUnsignedMax().zext(getBitWidth() * 2);
1024 
1025  ConstantRange Result_zext = ConstantRange(this_min * Other_min,
1026  this_max * Other_max + 1);
1027  ConstantRange UR = Result_zext.truncate(getBitWidth());
1028 
1029  // If the unsigned range doesn't wrap, and isn't negative then it's a range
1030  // from one positive number to another which is as good as we can generate.
1031  // In this case, skip the extra work of generating signed ranges which aren't
1032  // going to be better than this range.
1033  if (!UR.isUpperWrapped() &&
1034  (UR.getUpper().isNonNegative() || UR.getUpper().isMinSignedValue()))
1035  return UR;
1036 
1037  // Now the signed range. Because we could be dealing with negative numbers
1038  // here, the lower bound is the smallest of the cartesian product of the
1039  // lower and upper ranges; for example:
1040  // [-1,4) * [-2,3) = min(-1*-2, -1*2, 3*-2, 3*2) = -6.
1041  // Similarly for the upper bound, swapping min for max.
1042 
1043  this_min = getSignedMin().sext(getBitWidth() * 2);
1044  this_max = getSignedMax().sext(getBitWidth() * 2);
1045  Other_min = Other.getSignedMin().sext(getBitWidth() * 2);
1046  Other_max = Other.getSignedMax().sext(getBitWidth() * 2);
1047 
1048  auto L = {this_min * Other_min, this_min * Other_max,
1049  this_max * Other_min, this_max * Other_max};
1050  auto Compare = [](const APInt &A, const APInt &B) { return A.slt(B); };
1051  ConstantRange Result_sext(std::min(L, Compare), std::max(L, Compare) + 1);
1052  ConstantRange SR = Result_sext.truncate(getBitWidth());
1053 
1054  return UR.isSizeStrictlySmallerThan(SR) ? UR : SR;
1055 }
1056 
1058  if (isEmptySet() || Other.isEmptySet())
1059  return getEmpty();
1060 
1061  APInt Min = getSignedMin();
1062  APInt Max = getSignedMax();
1063  APInt OtherMin = Other.getSignedMin();
1064  APInt OtherMax = Other.getSignedMax();
1065 
1066  bool O1, O2, O3, O4;
1067  auto Muls = {Min.smul_ov(OtherMin, O1), Min.smul_ov(OtherMax, O2),
1068  Max.smul_ov(OtherMin, O3), Max.smul_ov(OtherMax, O4)};
1069  if (O1 || O2 || O3 || O4)
1070  return getFull();
1071 
1072  auto Compare = [](const APInt &A, const APInt &B) { return A.slt(B); };
1073  return getNonEmpty(std::min(Muls, Compare), std::max(Muls, Compare) + 1);
1074 }
1075 
1078  // X smax Y is: range(smax(X_smin, Y_smin),
1079  // smax(X_smax, Y_smax))
1080  if (isEmptySet() || Other.isEmptySet())
1081  return getEmpty();
1082  APInt NewL = APIntOps::smax(getSignedMin(), Other.getSignedMin());
1083  APInt NewU = APIntOps::smax(getSignedMax(), Other.getSignedMax()) + 1;
1084  ConstantRange Res = getNonEmpty(std::move(NewL), std::move(NewU));
1085  if (isSignWrappedSet() || Other.isSignWrappedSet())
1086  return Res.intersectWith(unionWith(Other, Signed), Signed);
1087  return Res;
1088 }
1089 
1092  // X umax Y is: range(umax(X_umin, Y_umin),
1093  // umax(X_umax, Y_umax))
1094  if (isEmptySet() || Other.isEmptySet())
1095  return getEmpty();
1096  APInt NewL = APIntOps::umax(getUnsignedMin(), Other.getUnsignedMin());
1097  APInt NewU = APIntOps::umax(getUnsignedMax(), Other.getUnsignedMax()) + 1;
1098  ConstantRange Res = getNonEmpty(std::move(NewL), std::move(NewU));
1099  if (isWrappedSet() || Other.isWrappedSet())
1101  return Res;
1102 }
1103 
1106  // X smin Y is: range(smin(X_smin, Y_smin),
1107  // smin(X_smax, Y_smax))
1108  if (isEmptySet() || Other.isEmptySet())
1109  return getEmpty();
1110  APInt NewL = APIntOps::smin(getSignedMin(), Other.getSignedMin());
1111  APInt NewU = APIntOps::smin(getSignedMax(), Other.getSignedMax()) + 1;
1112  ConstantRange Res = getNonEmpty(std::move(NewL), std::move(NewU));
1113  if (isSignWrappedSet() || Other.isSignWrappedSet())
1114  return Res.intersectWith(unionWith(Other, Signed), Signed);
1115  return Res;
1116 }
1117 
1120  // X umin Y is: range(umin(X_umin, Y_umin),
1121  // umin(X_umax, Y_umax))
1122  if (isEmptySet() || Other.isEmptySet())
1123  return getEmpty();
1124  APInt NewL = APIntOps::umin(getUnsignedMin(), Other.getUnsignedMin());
1125  APInt NewU = APIntOps::umin(getUnsignedMax(), Other.getUnsignedMax()) + 1;
1126  ConstantRange Res = getNonEmpty(std::move(NewL), std::move(NewU));
1127  if (isWrappedSet() || Other.isWrappedSet())
1129  return Res;
1130 }
1131 
1134  if (isEmptySet() || RHS.isEmptySet() || RHS.getUnsignedMax().isZero())
1135  return getEmpty();
1136 
1138 
1139  APInt RHS_umin = RHS.getUnsignedMin();
1140  if (RHS_umin.isZero()) {
1141  // We want the lowest value in RHS excluding zero. Usually that would be 1
1142  // except for a range in the form of [X, 1) in which case it would be X.
1143  if (RHS.getUpper() == 1)
1144  RHS_umin = RHS.getLower();
1145  else
1146  RHS_umin = 1;
1147  }
1148 
1149  APInt Upper = getUnsignedMax().udiv(RHS_umin) + 1;
1151 }
1152 
1154  // We split up the LHS and RHS into positive and negative components
1155  // and then also compute the positive and negative components of the result
1156  // separately by combining division results with the appropriate signs.
1157  APInt Zero = APInt::getZero(getBitWidth());
1159  ConstantRange PosFilter(APInt(getBitWidth(), 1), SignedMin);
1160  ConstantRange NegFilter(SignedMin, Zero);
1161  ConstantRange PosL = intersectWith(PosFilter);
1162  ConstantRange NegL = intersectWith(NegFilter);
1163  ConstantRange PosR = RHS.intersectWith(PosFilter);
1164  ConstantRange NegR = RHS.intersectWith(NegFilter);
1165 
1166  ConstantRange PosRes = getEmpty();
1167  if (!PosL.isEmptySet() && !PosR.isEmptySet())
1168  // pos / pos = pos.
1169  PosRes = ConstantRange(PosL.Lower.sdiv(PosR.Upper - 1),
1170  (PosL.Upper - 1).sdiv(PosR.Lower) + 1);
1171 
1172  if (!NegL.isEmptySet() && !NegR.isEmptySet()) {
1173  // neg / neg = pos.
1174  //
1175  // We need to deal with one tricky case here: SignedMin / -1 is UB on the
1176  // IR level, so we'll want to exclude this case when calculating bounds.
1177  // (For APInts the operation is well-defined and yields SignedMin.) We
1178  // handle this by dropping either SignedMin from the LHS or -1 from the RHS.
1179  APInt Lo = (NegL.Upper - 1).sdiv(NegR.Lower);
1180  if (NegL.Lower.isMinSignedValue() && NegR.Upper.isZero()) {
1181  // Remove -1 from the LHS. Skip if it's the only element, as this would
1182  // leave us with an empty set.
1183  if (!NegR.Lower.isAllOnes()) {
1184  APInt AdjNegRUpper;
1185  if (RHS.Lower.isAllOnes())
1186  // Negative part of [-1, X] without -1 is [SignedMin, X].
1187  AdjNegRUpper = RHS.Upper;
1188  else
1189  // [X, -1] without -1 is [X, -2].
1190  AdjNegRUpper = NegR.Upper - 1;
1191 
1192  PosRes = PosRes.unionWith(
1193  ConstantRange(Lo, NegL.Lower.sdiv(AdjNegRUpper - 1) + 1));
1194  }
1195 
1196  // Remove SignedMin from the RHS. Skip if it's the only element, as this
1197  // would leave us with an empty set.
1198  if (NegL.Upper != SignedMin + 1) {
1199  APInt AdjNegLLower;
1200  if (Upper == SignedMin + 1)
1201  // Negative part of [X, SignedMin] without SignedMin is [X, -1].
1202  AdjNegLLower = Lower;
1203  else
1204  // [SignedMin, X] without SignedMin is [SignedMin + 1, X].
1205  AdjNegLLower = NegL.Lower + 1;
1206 
1207  PosRes = PosRes.unionWith(
1209  AdjNegLLower.sdiv(NegR.Upper - 1) + 1));
1210  }
1211  } else {
1212  PosRes = PosRes.unionWith(
1213  ConstantRange(std::move(Lo), NegL.Lower.sdiv(NegR.Upper - 1) + 1));
1214  }
1215  }
1216 
1217  ConstantRange NegRes = getEmpty();
1218  if (!PosL.isEmptySet() && !NegR.isEmptySet())
1219  // pos / neg = neg.
1220  NegRes = ConstantRange((PosL.Upper - 1).sdiv(NegR.Upper - 1),
1221  PosL.Lower.sdiv(NegR.Lower) + 1);
1222 
1223  if (!NegL.isEmptySet() && !PosR.isEmptySet())
1224  // neg / pos = neg.
1225  NegRes = NegRes.unionWith(
1226  ConstantRange(NegL.Lower.sdiv(PosR.Lower),
1227  (NegL.Upper - 1).sdiv(PosR.Upper - 1) + 1));
1228 
1229  // Prefer a non-wrapping signed range here.
1230  ConstantRange Res = NegRes.unionWith(PosRes, PreferredRangeType::Signed);
1231 
1232  // Preserve the zero that we dropped when splitting the LHS by sign.
1233  if (contains(Zero) && (!PosR.isEmptySet() || !NegR.isEmptySet()))
1234  Res = Res.unionWith(ConstantRange(Zero));
1235  return Res;
1236 }
1237 
1239  if (isEmptySet() || RHS.isEmptySet() || RHS.getUnsignedMax().isZero())
1240  return getEmpty();
1241 
1242  if (const APInt *RHSInt = RHS.getSingleElement()) {
1243  // UREM by null is UB.
1244  if (RHSInt->isZero())
1245  return getEmpty();
1246  // Use APInt's implementation of UREM for single element ranges.
1247  if (const APInt *LHSInt = getSingleElement())
1248  return {LHSInt->urem(*RHSInt)};
1249  }
1250 
1251  // L % R for L < R is L.
1252  if (getUnsignedMax().ult(RHS.getUnsignedMin()))
1253  return *this;
1254 
1255  // L % R is <= L and < R.
1256  APInt Upper = APIntOps::umin(getUnsignedMax(), RHS.getUnsignedMax() - 1) + 1;
1258 }
1259 
1261  if (isEmptySet() || RHS.isEmptySet())
1262  return getEmpty();
1263 
1264  if (const APInt *RHSInt = RHS.getSingleElement()) {
1265  // SREM by null is UB.
1266  if (RHSInt->isZero())
1267  return getEmpty();
1268  // Use APInt's implementation of SREM for single element ranges.
1269  if (const APInt *LHSInt = getSingleElement())
1270  return {LHSInt->srem(*RHSInt)};
1271  }
1272 
1273  ConstantRange AbsRHS = RHS.abs();
1274  APInt MinAbsRHS = AbsRHS.getUnsignedMin();
1275  APInt MaxAbsRHS = AbsRHS.getUnsignedMax();
1276 
1277  // Modulus by zero is UB.
1278  if (MaxAbsRHS.isZero())
1279  return getEmpty();
1280 
1281  if (MinAbsRHS.isZero())
1282  ++MinAbsRHS;
1283 
1284  APInt MinLHS = getSignedMin(), MaxLHS = getSignedMax();
1285 
1286  if (MinLHS.isNonNegative()) {
1287  // L % R for L < R is L.
1288  if (MaxLHS.ult(MinAbsRHS))
1289  return *this;
1290 
1291  // L % R is <= L and < R.
1292  APInt Upper = APIntOps::umin(MaxLHS, MaxAbsRHS - 1) + 1;
1294  }
1295 
1296  // Same basic logic as above, but the result is negative.
1297  if (MaxLHS.isNegative()) {
1298  if (MinLHS.ugt(-MinAbsRHS))
1299  return *this;
1300 
1301  APInt Lower = APIntOps::umax(MinLHS, -MaxAbsRHS + 1);
1302  return ConstantRange(std::move(Lower), APInt(getBitWidth(), 1));
1303  }
1304 
1305  // LHS range crosses zero.
1306  APInt Lower = APIntOps::umax(MinLHS, -MaxAbsRHS + 1);
1307  APInt Upper = APIntOps::umin(MaxLHS, MaxAbsRHS - 1) + 1;
1309 }
1310 
1312  return ConstantRange(APInt::getAllOnes(getBitWidth())).sub(*this);
1313 }
1314 
1317  if (isEmptySet() || Other.isEmptySet())
1318  return getEmpty();
1319 
1320  // Use APInt's implementation of AND for single element ranges.
1321  if (isSingleElement() && Other.isSingleElement())
1322  return {*getSingleElement() & *Other.getSingleElement()};
1323 
1324  // TODO: replace this with something less conservative
1325 
1326  APInt umin = APIntOps::umin(Other.getUnsignedMax(), getUnsignedMax());
1328 }
1329 
1332  if (isEmptySet() || Other.isEmptySet())
1333  return getEmpty();
1334 
1335  // Use APInt's implementation of OR for single element ranges.
1336  if (isSingleElement() && Other.isSingleElement())
1337  return {*getSingleElement() | *Other.getSingleElement()};
1338 
1339  // TODO: replace this with something less conservative
1340 
1341  APInt umax = APIntOps::umax(getUnsignedMin(), Other.getUnsignedMin());
1343 }
1344 
1346  if (isEmptySet() || Other.isEmptySet())
1347  return getEmpty();
1348 
1349  // Use APInt's implementation of XOR for single element ranges.
1350  if (isSingleElement() && Other.isSingleElement())
1351  return {*getSingleElement() ^ *Other.getSingleElement()};
1352 
1353  // Special-case binary complement, since we can give a precise answer.
1354  if (Other.isSingleElement() && Other.getSingleElement()->isAllOnes())
1355  return binaryNot();
1356  if (isSingleElement() && getSingleElement()->isAllOnes())
1357  return Other.binaryNot();
1358 
1359  // TODO: replace this with something less conservative
1360  return getFull();
1361 }
1362 
1365  if (isEmptySet() || Other.isEmptySet())
1366  return getEmpty();
1367 
1368  APInt Min = getUnsignedMin();
1369  APInt Max = getUnsignedMax();
1370  if (const APInt *RHS = Other.getSingleElement()) {
1371  unsigned BW = getBitWidth();
1372  if (RHS->uge(BW))
1373  return getEmpty();
1374 
1375  unsigned EqualLeadingBits = (Min ^ Max).countLeadingZeros();
1376  if (RHS->ule(EqualLeadingBits))
1377  return getNonEmpty(Min << *RHS, (Max << *RHS) + 1);
1378 
1379  return getNonEmpty(APInt::getZero(BW),
1380  APInt::getBitsSetFrom(BW, RHS->getZExtValue()) + 1);
1381  }
1382 
1383  APInt OtherMax = Other.getUnsignedMax();
1384 
1385  // There's overflow!
1386  if (OtherMax.ugt(Max.countLeadingZeros()))
1387  return getFull();
1388 
1389  // FIXME: implement the other tricky cases
1390 
1391  Min <<= Other.getUnsignedMin();
1392  Max <<= OtherMax;
1393 
1394  return ConstantRange::getNonEmpty(std::move(Min), std::move(Max) + 1);
1395 }
1396 
1399  if (isEmptySet() || Other.isEmptySet())
1400  return getEmpty();
1401 
1402  APInt max = getUnsignedMax().lshr(Other.getUnsignedMin()) + 1;
1403  APInt min = getUnsignedMin().lshr(Other.getUnsignedMax());
1404  return getNonEmpty(std::move(min), std::move(max));
1405 }
1406 
1409  if (isEmptySet() || Other.isEmptySet())
1410  return getEmpty();
1411 
1412  // May straddle zero, so handle both positive and negative cases.
1413  // 'PosMax' is the upper bound of the result of the ashr
1414  // operation, when Upper of the LHS of ashr is a non-negative.
1415  // number. Since ashr of a non-negative number will result in a
1416  // smaller number, the Upper value of LHS is shifted right with
1417  // the minimum value of 'Other' instead of the maximum value.
1418  APInt PosMax = getSignedMax().ashr(Other.getUnsignedMin()) + 1;
1419 
1420  // 'PosMin' is the lower bound of the result of the ashr
1421  // operation, when Lower of the LHS is a non-negative number.
1422  // Since ashr of a non-negative number will result in a smaller
1423  // number, the Lower value of LHS is shifted right with the
1424  // maximum value of 'Other'.
1425  APInt PosMin = getSignedMin().ashr(Other.getUnsignedMax());
1426 
1427  // 'NegMax' is the upper bound of the result of the ashr
1428  // operation, when Upper of the LHS of ashr is a negative number.
1429  // Since 'ashr' of a negative number will result in a bigger
1430  // number, the Upper value of LHS is shifted right with the
1431  // maximum value of 'Other'.
1432  APInt NegMax = getSignedMax().ashr(Other.getUnsignedMax()) + 1;
1433 
1434  // 'NegMin' is the lower bound of the result of the ashr
1435  // operation, when Lower of the LHS of ashr is a negative number.
1436  // Since 'ashr' of a negative number will result in a bigger
1437  // number, the Lower value of LHS is shifted right with the
1438  // minimum value of 'Other'.
1439  APInt NegMin = getSignedMin().ashr(Other.getUnsignedMin());
1440 
1441  APInt max, min;
1442  if (getSignedMin().isNonNegative()) {
1443  // Upper and Lower of LHS are non-negative.
1444  min = PosMin;
1445  max = PosMax;
1446  } else if (getSignedMax().isNegative()) {
1447  // Upper and Lower of LHS are negative.
1448  min = NegMin;
1449  max = NegMax;
1450  } else {
1451  // Upper is non-negative and Lower is negative.
1452  min = NegMin;
1453  max = PosMax;
1454  }
1455  return getNonEmpty(std::move(min), std::move(max));
1456 }
1457 
1459  if (isEmptySet() || Other.isEmptySet())
1460  return getEmpty();
1461 
1462  APInt NewL = getUnsignedMin().uadd_sat(Other.getUnsignedMin());
1463  APInt NewU = getUnsignedMax().uadd_sat(Other.getUnsignedMax()) + 1;
1464  return getNonEmpty(std::move(NewL), std::move(NewU));
1465 }
1466 
1468  if (isEmptySet() || Other.isEmptySet())
1469  return getEmpty();
1470 
1471  APInt NewL = getSignedMin().sadd_sat(Other.getSignedMin());
1472  APInt NewU = getSignedMax().sadd_sat(Other.getSignedMax()) + 1;
1473  return getNonEmpty(std::move(NewL), std::move(NewU));
1474 }
1475 
1477  if (isEmptySet() || Other.isEmptySet())
1478  return getEmpty();
1479 
1480  APInt NewL = getUnsignedMin().usub_sat(Other.getUnsignedMax());
1481  APInt NewU = getUnsignedMax().usub_sat(Other.getUnsignedMin()) + 1;
1482  return getNonEmpty(std::move(NewL), std::move(NewU));
1483 }
1484 
1486  if (isEmptySet() || Other.isEmptySet())
1487  return getEmpty();
1488 
1489  APInt NewL = getSignedMin().ssub_sat(Other.getSignedMax());
1490  APInt NewU = getSignedMax().ssub_sat(Other.getSignedMin()) + 1;
1491  return getNonEmpty(std::move(NewL), std::move(NewU));
1492 }
1493 
1495  if (isEmptySet() || Other.isEmptySet())
1496  return getEmpty();
1497 
1498  APInt NewL = getUnsignedMin().umul_sat(Other.getUnsignedMin());
1499  APInt NewU = getUnsignedMax().umul_sat(Other.getUnsignedMax()) + 1;
1500  return getNonEmpty(std::move(NewL), std::move(NewU));
1501 }
1502 
1504  if (isEmptySet() || Other.isEmptySet())
1505  return getEmpty();
1506 
1507  // Because we could be dealing with negative numbers here, the lower bound is
1508  // the smallest of the cartesian product of the lower and upper ranges;
1509  // for example:
1510  // [-1,4) * [-2,3) = min(-1*-2, -1*2, 3*-2, 3*2) = -6.
1511  // Similarly for the upper bound, swapping min for max.
1512 
1513  APInt this_min = getSignedMin().sext(getBitWidth() * 2);
1514  APInt this_max = getSignedMax().sext(getBitWidth() * 2);
1515  APInt Other_min = Other.getSignedMin().sext(getBitWidth() * 2);
1516  APInt Other_max = Other.getSignedMax().sext(getBitWidth() * 2);
1517 
1518  auto L = {this_min * Other_min, this_min * Other_max, this_max * Other_min,
1519  this_max * Other_max};
1520  auto Compare = [](const APInt &A, const APInt &B) { return A.slt(B); };
1521 
1522  // Note that we wanted to perform signed saturating multiplication,
1523  // so since we performed plain multiplication in twice the bitwidth,
1524  // we need to perform signed saturating truncation.
1525  return getNonEmpty(std::min(L, Compare).truncSSat(getBitWidth()),
1526  std::max(L, Compare).truncSSat(getBitWidth()) + 1);
1527 }
1528 
1530  if (isEmptySet() || Other.isEmptySet())
1531  return getEmpty();
1532 
1533  APInt NewL = getUnsignedMin().ushl_sat(Other.getUnsignedMin());
1534  APInt NewU = getUnsignedMax().ushl_sat(Other.getUnsignedMax()) + 1;
1535  return getNonEmpty(std::move(NewL), std::move(NewU));
1536 }
1537 
1539  if (isEmptySet() || Other.isEmptySet())
1540  return getEmpty();
1541 
1542  APInt Min = getSignedMin(), Max = getSignedMax();
1543  APInt ShAmtMin = Other.getUnsignedMin(), ShAmtMax = Other.getUnsignedMax();
1544  APInt NewL = Min.sshl_sat(Min.isNonNegative() ? ShAmtMin : ShAmtMax);
1545  APInt NewU = Max.sshl_sat(Max.isNegative() ? ShAmtMin : ShAmtMax) + 1;
1546  return getNonEmpty(std::move(NewL), std::move(NewU));
1547 }
1548 
1550  if (isFullSet())
1551  return getEmpty();
1552  if (isEmptySet())
1553  return getFull();
1554  return ConstantRange(Upper, Lower);
1555 }
1556 
1557 ConstantRange ConstantRange::abs(bool IntMinIsPoison) const {
1558  if (isEmptySet())
1559  return getEmpty();
1560 
1561  if (isSignWrappedSet()) {
1562  APInt Lo;
1563  // Check whether the range crosses zero.
1564  if (Upper.isStrictlyPositive() || !Lower.isStrictlyPositive())
1566  else
1567  Lo = APIntOps::umin(Lower, -Upper + 1);
1568 
1569  // If SignedMin is not poison, then it is included in the result range.
1570  if (IntMinIsPoison)
1572  else
1574  }
1575 
1577 
1578  // Skip SignedMin if it is poison.
1579  if (IntMinIsPoison && SMin.isMinSignedValue()) {
1580  // The range may become empty if it *only* contains SignedMin.
1581  if (SMax.isMinSignedValue())
1582  return getEmpty();
1583  ++SMin;
1584  }
1585 
1586  // All non-negative.
1587  if (SMin.isNonNegative())
1588  return *this;
1589 
1590  // All negative.
1591  if (SMax.isNegative())
1592  return ConstantRange(-SMax, -SMin + 1);
1593 
1594  // Range crosses zero.
1596  APIntOps::umax(-SMin, SMax) + 1);
1597 }
1598 
1600  const ConstantRange &Other) const {
1601  if (isEmptySet() || Other.isEmptySet())
1603 
1604  APInt Min = getUnsignedMin(), Max = getUnsignedMax();
1605  APInt OtherMin = Other.getUnsignedMin(), OtherMax = Other.getUnsignedMax();
1606 
1607  // a u+ b overflows high iff a u> ~b.
1608  if (Min.ugt(~OtherMin))
1610  if (Max.ugt(~OtherMax))
1613 }
1614 
1616  const ConstantRange &Other) const {
1617  if (isEmptySet() || Other.isEmptySet())
1619 
1620  APInt Min = getSignedMin(), Max = getSignedMax();
1621  APInt OtherMin = Other.getSignedMin(), OtherMax = Other.getSignedMax();
1622 
1625 
1626  // a s+ b overflows high iff a s>=0 && b s>= 0 && a s> smax - b.
1627  // a s+ b overflows low iff a s< 0 && b s< 0 && a s< smin - b.
1628  if (Min.isNonNegative() && OtherMin.isNonNegative() &&
1629  Min.sgt(SignedMax - OtherMin))
1631  if (Max.isNegative() && OtherMax.isNegative() &&
1632  Max.slt(SignedMin - OtherMax))
1634 
1635  if (Max.isNonNegative() && OtherMax.isNonNegative() &&
1636  Max.sgt(SignedMax - OtherMax))
1638  if (Min.isNegative() && OtherMin.isNegative() &&
1639  Min.slt(SignedMin - OtherMin))
1641 
1643 }
1644 
1646  const ConstantRange &Other) const {
1647  if (isEmptySet() || Other.isEmptySet())
1649 
1650  APInt Min = getUnsignedMin(), Max = getUnsignedMax();
1651  APInt OtherMin = Other.getUnsignedMin(), OtherMax = Other.getUnsignedMax();
1652 
1653  // a u- b overflows low iff a u< b.
1654  if (Max.ult(OtherMin))
1656  if (Min.ult(OtherMax))
1659 }
1660 
1662  const ConstantRange &Other) const {
1663  if (isEmptySet() || Other.isEmptySet())
1665 
1666  APInt Min = getSignedMin(), Max = getSignedMax();
1667  APInt OtherMin = Other.getSignedMin(), OtherMax = Other.getSignedMax();
1668 
1671 
1672  // a s- b overflows high iff a s>=0 && b s< 0 && a s> smax + b.
1673  // a s- b overflows low iff a s< 0 && b s>= 0 && a s< smin + b.
1674  if (Min.isNonNegative() && OtherMax.isNegative() &&
1675  Min.sgt(SignedMax + OtherMax))
1677  if (Max.isNegative() && OtherMin.isNonNegative() &&
1678  Max.slt(SignedMin + OtherMin))
1680 
1681  if (Max.isNonNegative() && OtherMin.isNegative() &&
1682  Max.sgt(SignedMax + OtherMin))
1684  if (Min.isNegative() && OtherMax.isNonNegative() &&
1685  Min.slt(SignedMin + OtherMax))
1687 
1689 }
1690 
1692  const ConstantRange &Other) const {
1693  if (isEmptySet() || Other.isEmptySet())
1695 
1696  APInt Min = getUnsignedMin(), Max = getUnsignedMax();
1697  APInt OtherMin = Other.getUnsignedMin(), OtherMax = Other.getUnsignedMax();
1698  bool Overflow;
1699 
1700  (void) Min.umul_ov(OtherMin, Overflow);
1701  if (Overflow)
1703 
1704  (void) Max.umul_ov(OtherMax, Overflow);
1705  if (Overflow)
1707 
1709 }
1710 
1712  if (isFullSet())
1713  OS << "full-set";
1714  else if (isEmptySet())
1715  OS << "empty-set";
1716  else
1717  OS << "[" << Lower << "," << Upper << ")";
1718 }
1719 
1720 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1722  print(dbgs());
1723 }
1724 #endif
1725 
1727  const unsigned NumRanges = Ranges.getNumOperands() / 2;
1728  assert(NumRanges >= 1 && "Must have at least one range!");
1729  assert(Ranges.getNumOperands() % 2 == 0 && "Must be a sequence of pairs");
1730 
1731  auto *FirstLow = mdconst::extract<ConstantInt>(Ranges.getOperand(0));
1732  auto *FirstHigh = mdconst::extract<ConstantInt>(Ranges.getOperand(1));
1733 
1734  ConstantRange CR(FirstLow->getValue(), FirstHigh->getValue());
1735 
1736  for (unsigned i = 1; i < NumRanges; ++i) {
1737  auto *Low = mdconst::extract<ConstantInt>(Ranges.getOperand(2 * i + 0));
1738  auto *High = mdconst::extract<ConstantInt>(Ranges.getOperand(2 * i + 1));
1739 
1740  // Note: unionWith will potentially create a range that contains values not
1741  // contained in any of the original N ranges.
1742  CR = CR.unionWith(ConstantRange(Low->getValue(), High->getValue()));
1743  }
1744 
1745  return CR;
1746 }
llvm::ConstantRange::isFullSet
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type.
Definition: ConstantRange.cpp:309
i
i
Definition: README.txt:29
llvm::APInt::isStrictlyPositive
bool isStrictlyPositive() const
Determine if this APInt Value is positive.
Definition: APInt.h:339
llvm::ConstantRange::signExtend
ConstantRange signExtend(uint32_t BitWidth) const
Return a new range in the specified integer type, which must be strictly larger than the current type...
Definition: ConstantRange.cpp:706
llvm::ConstantRange::binaryOr
ConstantRange binaryOr(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a binary-or of a value in this ran...
Definition: ConstantRange.cpp:1331
llvm::APInt::setAllBits
void setAllBits()
Set every bit to 1.
Definition: APInt.h:1268
Signed
@ Signed
Definition: NVPTXISelLowering.cpp:4636
LLVM_DUMP_METHOD
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:506
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::ConstantRange::OverflowResult::AlwaysOverflowsLow
@ AlwaysOverflowsLow
Always overflows in the direction of signed/unsigned min value.
llvm::CmpInst::ICMP_EQ
@ ICMP_EQ
equal
Definition: InstrTypes.h:741
llvm::ConstantRange::ushl_sat
ConstantRange ushl_sat(const ConstantRange &Other) const
Perform an unsigned saturating left shift of this constant range by a value in Other.
Definition: ConstantRange.cpp:1529
llvm::HexPrintStyle::Upper
@ Upper
llvm::ConstantRange::binaryAnd
ConstantRange binaryAnd(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a binary-and of a value in this ra...
Definition: ConstantRange.cpp:1316
Metadata.h
llvm::CmpInst::Predicate
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:720
llvm::ConstantRange::sdiv
ConstantRange sdiv(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a signed division of a value in th...
Definition: ConstantRange.cpp:1153
llvm::ConstantRange::sub
ConstantRange sub(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a subtraction of a value in this r...
Definition: ConstantRange.cpp:954
llvm::ConstantRange::dump
void dump() const
Allow printing from a debugger easily.
Definition: ConstantRange.cpp:1721
llvm::KnownBits::getMinValue
APInt getMinValue() const
Return the minimal unsigned value possible given these KnownBits.
Definition: KnownBits.h:120
llvm::ConstantRange::umul_sat
ConstantRange umul_sat(const ConstantRange &Other) const
Perform an unsigned saturating multiplication of two constant ranges.
Definition: ConstantRange.cpp:1494
llvm::APInt::ule
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
Definition: APInt.h:1082
llvm::ConstantRange::udiv
ConstantRange udiv(const ConstantRange &Other) const
Return a new range representing the possible values resulting from an unsigned division of a value in...
Definition: ConstantRange.cpp:1133
llvm::ConstantRange::ssub_sat
ConstantRange ssub_sat(const ConstantRange &Other) const
Perform a signed saturating subtraction of two constant ranges.
Definition: ConstantRange.cpp:1485
High
uint64_t High
Definition: NVVMIntrRange.cpp:61
llvm::RISCVFenceField::W
@ W
Definition: RISCVBaseInfo.h:199
llvm::KnownBits::isUnknown
bool isUnknown() const
Returns true if we don't know any bits.
Definition: KnownBits.h:63
llvm::APInt::getMinValue
static APInt getMinValue(unsigned numBits)
Gets minimum unsigned value of APInt for a specific bit width.
Definition: APInt.h:196
llvm::ConstantRange::OverflowResult::AlwaysOverflowsHigh
@ AlwaysOverflowsHigh
Always overflows in the direction of signed/unsigned max value.
llvm::MipsISD::Lo
@ Lo
Definition: MipsISelLowering.h:79
ErrorHandling.h
llvm::APInt::getMaxValue
static APInt getMaxValue(unsigned numBits)
Gets maximum unsigned value of APInt for specific bit width.
Definition: APInt.h:186
llvm::ConstantRange::isUpperSignWrapped
bool isUpperSignWrapped() const
Return true if the (exclusive) upper bound wraps around the signed domain.
Definition: ConstantRange.cpp:329
llvm::ConstantRange::isAllNonNegative
bool isAllNonNegative() const
Return true if all values in this range are non-negative.
Definition: ConstantRange.cpp:364
llvm::CmpInst::ICMP_NE
@ ICMP_NE
not equal
Definition: InstrTypes.h:742
llvm::CmpInst::getInversePredicate
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE,...
Definition: InstrTypes.h:820
llvm::APInt::isOne
bool isOne() const
Determine if this is a value of 1.
Definition: APInt.h:371
llvm::ConstantRange::getEquivalentICmp
bool getEquivalentICmp(CmpInst::Predicate &Pred, APInt &RHS) const
Set up Pred and RHS such that ConstantRange::makeExactICmpRegion(Pred, RHS) == *this.
Definition: ConstantRange.cpp:150
APInt.h
llvm::CmpInst::ICMP_SGT
@ ICMP_SGT
signed greater than
Definition: InstrTypes.h:747
llvm::APInt::getSignedMaxValue
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
Definition: APInt.h:189
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::APInt::getBitWidth
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition: APInt.h:1410
llvm::ConstantRange::isSignWrappedSet
bool isSignWrappedSet() const
Return true if this set wraps around the signed domain.
Definition: ConstantRange.cpp:325
llvm::ConstantRange::uadd_sat
ConstantRange uadd_sat(const ConstantRange &Other) const
Perform an unsigned saturating addition of two constant ranges.
Definition: ConstantRange.cpp:1458
llvm::APInt::ugt
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
Definition: APInt.h:1114
llvm::ConstantRange::multiply
ConstantRange multiply(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a multiplication of a value in thi...
Definition: ConstantRange.cpp:1004
llvm::ConstantRange::shl
ConstantRange shl(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a left shift of a value in this ra...
Definition: ConstantRange.cpp:1364
Operator.h
llvm::CmpInst::ICMP_SLE
@ ICMP_SLE
signed less or equal
Definition: InstrTypes.h:750
llvm::ConstantRange::sshl_sat
ConstantRange sshl_sat(const ConstantRange &Other) const
Perform a signed saturating left shift of this constant range by a value in Other.
Definition: ConstantRange.cpp:1538
llvm::APInt::lshr
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
Definition: APInt.h:815
llvm::getConstantRangeFromMetadata
ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD)
Parse out a conservative ConstantRange from !range metadata.
Definition: ConstantRange.cpp:1726
llvm::RecurKind::SMin
@ SMin
Signed integer min implemented in terms of select(cmp()).
llvm::JumpTable::Full
@ Full
Definition: TargetOptions.h:50
llvm::APInt::Rounding::UP
@ UP
llvm::ConstantRange::unsignedAddMayOverflow
OverflowResult unsignedAddMayOverflow(const ConstantRange &Other) const
Return whether unsigned add of the two ranges always/never overflows.
Definition: ConstantRange.cpp:1599
llvm::APInt::getZero
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
Definition: APInt.h:177
llvm::ConstantRange::makeAllowedICmpRegion
static ConstantRange makeAllowedICmpRegion(CmpInst::Predicate Pred, const ConstantRange &Other)
Produce the smallest range such that all values that may satisfy the given predicate with any value c...
Definition: ConstantRange.cpp:78
llvm::ConstantRange::isIntrinsicSupported
static bool isIntrinsicSupported(Intrinsic::ID IntrinsicID)
Returns true if ConstantRange calculations are supported for intrinsic with IntrinsicID.
Definition: ConstantRange.cpp:858
llvm::APIntOps::umin
const APInt & umin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be unsigned.
Definition: APInt.h:2128
llvm::ConstantRange::OverflowResult
OverflowResult
Represents whether an operation on the given constant range is known to always or never overflow.
Definition: ConstantRange.h:495
getPreferredRange
static ConstantRange getPreferredRange(const ConstantRange &CR1, const ConstantRange &CR2, ConstantRange::PreferredRangeType Type)
Definition: ConstantRange.cpp:447
KnownBits.h
llvm::ConstantRange::binaryOp
ConstantRange binaryOp(Instruction::BinaryOps BinOp, const ConstantRange &Other) const
Return a new range representing the possible values resulting from an application of the specified bi...
Definition: ConstantRange.cpp:796
llvm::MDNode::getNumOperands
unsigned getNumOperands() const
Return number of MDNode operands.
Definition: Metadata.h:1143
llvm::ConstantRange::signedSubMayOverflow
OverflowResult signedSubMayOverflow(const ConstantRange &Other) const
Return whether signed sub of the two ranges always/never overflows.
Definition: ConstantRange.cpp:1661
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::ConstantRange::Signed
@ Signed
Definition: ConstantRange.h:292
Instruction.h
llvm::APInt::umul_ov
APInt umul_ov(const APInt &RHS, bool &Overflow) const
Definition: APInt.cpp:1963
llvm::APInt::uge
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
Definition: APInt.h:1152
llvm::KnownBits::isNonNegative
bool isNonNegative() const
Returns true if this value is known to be non-negative.
Definition: KnownBits.h:99
llvm::APInt::isNonNegative
bool isNonNegative() const
Determine if this APInt Value is non-negative (>= 0)
Definition: APInt.h:317
llvm::APInt::isNegative
bool isNegative() const
Determine sign of this APInt.
Definition: APInt.h:312
llvm::ConstantRange::binaryXor
ConstantRange binaryXor(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a binary-xor of a value in this ra...
Definition: ConstantRange.cpp:1345
Constants.h
llvm::APInt::isZero
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
Definition: APInt.h:359
llvm::ConstantRange::isWrappedSet
bool isWrappedSet() const
Return true if this set wraps around the unsigned domain.
Definition: ConstantRange.cpp:317
llvm::ConstantRange::getUnsignedMin
APInt getUnsignedMin() const
Return the smallest unsigned value contained in the ConstantRange.
Definition: ConstantRange.cpp:375
Intrinsics.h
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::APInt::usub_sat
APInt usub_sat(const APInt &RHS) const
Definition: APInt.cpp:2032
llvm::CmpInst::ICMP_ULE
@ ICMP_ULE
unsigned less or equal
Definition: InstrTypes.h:746
InstrTypes.h
llvm::ConstantRange::PreferredRangeType
PreferredRangeType
If represented precisely, the result of some range operations may consist of multiple disjoint ranges...
Definition: ConstantRange.h:292
llvm::ConstantRange::isSingleElement
bool isSingleElement() const
Return true if this set contains exactly one member.
Definition: ConstantRange.h:234
llvm::ConstantRange::abs
ConstantRange abs(bool IntMinIsPoison=false) const
Calculate absolute value range.
Definition: ConstantRange.cpp:1557
llvm::APInt::getAllOnes
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
Definition: APInt.h:214
llvm::KnownBits::hasConflict
bool hasConflict() const
Returns true if there is conflicting information.
Definition: KnownBits.h:47
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::ConstantRange::makeGuaranteedNoWrapRegion
static ConstantRange makeGuaranteedNoWrapRegion(Instruction::BinaryOps BinOp, const ConstantRange &Other, unsigned NoWrapKind)
Produce the largest range containing all X such that "X BinOp Y" is guaranteed not to wrap (overflow)...
Definition: ConstantRange.cpp:231
llvm::ConstantRange::srem
ConstantRange srem(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a signed remainder operation of a ...
Definition: ConstantRange.cpp:1260
llvm::Instruction::CastOps
CastOps
Definition: Instruction.h:799
llvm::ConstantRange::getUnsignedMax
APInt getUnsignedMax() const
Return the largest unsigned value contained in the ConstantRange.
Definition: ConstantRange.cpp:369
llvm::APInt::isAllOnes
bool isAllOnes() const
Determine if all bits are set. This is true for zero-width values.
Definition: APInt.h:347
llvm::ConstantRange::lshr
ConstantRange lshr(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a logical right shift of a value i...
Definition: ConstantRange.cpp:1398
llvm::ConstantRange::isUpperWrapped
bool isUpperWrapped() const
Return true if the exclusive upper bound wraps around the unsigned domain.
Definition: ConstantRange.cpp:321
llvm::ConstantRange::unionWith
ConstantRange unionWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the union of this range with another range.
Definition: ConstantRange.cpp:573
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::APInt::getHighBitsSet
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Constructs an APInt value that has the top hiBitsSet bits set.
Definition: APInt.h:279
llvm::ConstantRange::Unsigned
@ Unsigned
Definition: ConstantRange.h:292
llvm::KnownBits::isNegative
bool isNegative() const
Returns true if this value is known to be negative.
Definition: KnownBits.h:96
llvm::ConstantRange::add
ConstantRange add(const ConstantRange &Other) const
Return a new range representing the possible values resulting from an addition of a value in this ran...
Definition: ConstantRange.cpp:907
llvm::ConstantRange::isSizeLargerThan
bool isSizeLargerThan(uint64_t MaxSize) const
Compare set size of this range with Value.
Definition: ConstantRange.cpp:344
llvm::ConstantRange::smul_fast
ConstantRange smul_fast(const ConstantRange &Other) const
Return range of possible values for a signed multiplication of this and Other.
Definition: ConstantRange.cpp:1057
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
llvm::RecurKind::UMin
@ UMin
Unisgned integer min implemented in terms of select(cmp()).
llvm::ConstantRange::intrinsic
static ConstantRange intrinsic(Intrinsic::ID IntrinsicID, ArrayRef< ConstantRange > Ops)
Compute range of intrinsic result for the given operand ranges.
Definition: ConstantRange.cpp:875
llvm::APInt::ashr
APInt ashr(unsigned ShiftAmt) const
Arithmetic right-shift function.
Definition: APInt.h:791
llvm::ConstantRange::overflowingBinaryOp
ConstantRange overflowingBinaryOp(Instruction::BinaryOps BinOp, const ConstantRange &Other, unsigned NoWrapKind) const
Return a new range representing the possible values resulting from an application of the specified ov...
Definition: ConstantRange.cpp:841
llvm::APInt::getOneBitSet
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
Definition: APInt.h:222
llvm::MDNode::getOperand
const MDOperand & getOperand(unsigned I) const
Definition: Metadata.h:1137
llvm::ConstantRange::castOp
ConstantRange castOp(Instruction::CastOps CastOp, uint32_t BitWidth) const
Return a new range representing the possible values resulting from an application of the specified ca...
Definition: ConstantRange.cpp:646
llvm::LegacyLegalizeActions::Lower
@ Lower
The operation itself must be expressed in terms of simpler actions on this target.
Definition: LegacyLegalizerInfo.h:58
llvm::ConstantRange::isAllNegative
bool isAllNegative() const
Return true if all values in this range are negative.
Definition: ConstantRange.cpp:354
llvm::ConstantRange::zeroExtend
ConstantRange zeroExtend(uint32_t BitWidth) const
Return a new range in the specified integer type, which must be strictly larger than the current type...
Definition: ConstantRange.cpp:689
llvm::APInt::slt
bool slt(const APInt &RHS) const
Signed less than comparison.
Definition: APInt.h:1063
llvm::ConstantRange::inverse
ConstantRange inverse() const
Return a new range that is the logical not of the current set.
Definition: ConstantRange.cpp:1549
llvm::ConstantRange::getBitWidth
uint32_t getBitWidth() const
Get the bit width of this ConstantRange.
Definition: ConstantRange.h:177
llvm::APInt::sdiv
APInt sdiv(const APInt &RHS) const
Signed division function for APInt.
Definition: APInt.cpp:1636
uint64_t
llvm::ConstantRange::getSignedMin
APInt getSignedMin() const
Return the smallest signed value contained in the ConstantRange.
Definition: ConstantRange.cpp:387
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::APInt::sextOrSelf
APInt sextOrSelf(unsigned width) const
Sign extend or truncate to width.
Definition: APInt.cpp:998
llvm::ConstantRange::zextOrTrunc
ConstantRange zextOrTrunc(uint32_t BitWidth) const
Make this range have the bit width given by BitWidth.
Definition: ConstantRange.cpp:778
llvm::KnownBits::getMaxValue
APInt getMaxValue() const
Return the maximal unsigned value possible given these KnownBits.
Definition: KnownBits.h:136
llvm::ConstantRange::smul_sat
ConstantRange smul_sat(const ConstantRange &Other) const
Perform a signed saturating multiplication of two constant ranges.
Definition: ConstantRange.cpp:1503
llvm::APInt::getBoolValue
bool getBoolValue() const
Convert APInt to a boolean value.
Definition: APInt.h:452
llvm::ConstantRange::addWithNoWrap
ConstantRange addWithNoWrap(const ConstantRange &Other, unsigned NoWrapKind, PreferredRangeType RangeType=Smallest) const
Return a new range representing the possible values resulting from an addition with wrap type NoWrapK...
Definition: ConstantRange.cpp:926
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1609
llvm::ConstantRange::truncate
ConstantRange truncate(uint32_t BitWidth) const
Return a new range in the specified integer type, which must be strictly smaller than the current typ...
Definition: ConstantRange.cpp:724
llvm::ConstantRange::sadd_sat
ConstantRange sadd_sat(const ConstantRange &Other) const
Perform a signed saturating addition of two constant ranges.
Definition: ConstantRange.cpp:1467
llvm::CmpInst::ICMP_UGE
@ ICMP_UGE
unsigned greater or equal
Definition: InstrTypes.h:744
llvm::Instruction::isBinaryOp
bool isBinaryOp() const
Definition: Instruction.h:165
llvm::ConstantRange::unsignedMulMayOverflow
OverflowResult unsignedMulMayOverflow(const ConstantRange &Other) const
Return whether unsigned mul of the two ranges always/never overflows.
Definition: ConstantRange.cpp:1691
llvm::MDNode
Metadata node.
Definition: Metadata.h:906
llvm::ConstantRange::smax
ConstantRange smax(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a signed maximum of a value in thi...
Definition: ConstantRange.cpp:1077
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:75
llvm::ConstantRange::getSingleElement
const APInt * getSingleElement() const
If this set contains a single element, return it, otherwise return null.
Definition: ConstantRange.h:219
llvm::CmpInst::ICMP_SLT
@ ICMP_SLT
signed less than
Definition: InstrTypes.h:749
Compare
QP Compare Ordered outs ins xscmpudp No builtin are required Or llvm fcmp order unorder compare DP QP Compare builtin are required DP Compare
Definition: README_P9.txt:309
llvm::APIntOps::smin
const APInt & smin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be signed.
Definition: APInt.h:2118
llvm::RecurKind::UMax
@ UMax
Unsigned integer max implemented in terms of select(cmp()).
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::min
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:357
llvm::APInt::zextOrSelf
APInt zextOrSelf(unsigned width) const
Zero extend or truncate to width.
Definition: APInt.cpp:992
llvm::APInt::sshl_sat
APInt sshl_sat(const APInt &RHS) const
Definition: APInt.cpp:2063
llvm::CmpInst::ICMP_ULT
@ ICMP_ULT
unsigned less than
Definition: InstrTypes.h:745
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:134
A
* A
Definition: README_ALTIVEC.txt:89
uint32_t
makeExactMulNSWRegion
static ConstantRange makeExactMulNSWRegion(const APInt &V)
Exact mul nsw region for single element RHS.
Definition: ConstantRange.cpp:203
Compiler.h
llvm::ConstantRange::umax
ConstantRange umax(const ConstantRange &Other) const
Return a new range representing the possible values resulting from an unsigned maximum of a value in ...
Definition: ConstantRange.cpp:1091
llvm::APInt::ushl_sat
APInt ushl_sat(const APInt &RHS) const
Definition: APInt.cpp:2073
ConstantRange.h
llvm::APIntOps::RoundingSDiv
APInt RoundingSDiv(const APInt &A, const APInt &B, APInt::Rounding RM)
Return A sign-divided by B, rounded by the given rounding mode.
Definition: APInt.cpp:2737
llvm::ConstantRange::ConstantRange
ConstantRange(uint32_t BitWidth, bool isFullSet)
Initialize a full or empty set for the specified bit width.
Definition: ConstantRange.cpp:43
llvm::OverflowingBinaryOperator
Utility class for integer operators which may exhibit overflow - Add, Sub, Mul, and Shl.
Definition: Operator.h:67
llvm::APInt::umul_sat
APInt umul_sat(const APInt &RHS) const
Definition: APInt.cpp:2054
llvm::APInt::ult
bool ult(const APInt &RHS) const
Unsigned less than comparison.
Definition: APInt.h:1044
llvm::APInt::udiv
APInt udiv(const APInt &RHS) const
Unsigned division operation.
Definition: APInt.cpp:1565
llvm::APInt::clearBit
void clearBit(unsigned BitPosition)
Set a given bit to 0.
Definition: APInt.h:1356
llvm::APInt::zext
APInt zext(unsigned width) const
Zero extend to a new width.
Definition: APInt.cpp:952
llvm::APInt::Rounding::DOWN
@ DOWN
llvm::ConstantRange::isSizeStrictlySmallerThan
bool isSizeStrictlySmallerThan(const ConstantRange &CR) const
Compare set size of this range with the range CR.
Definition: ConstantRange.cpp:334
llvm::APInt::ssub_sat
APInt ssub_sat(const APInt &RHS) const
Definition: APInt.cpp:2022
llvm::ConstantRange::difference
ConstantRange difference(const ConstantRange &CR) const
Subtract the specified range from this range (aka relative complement of the sets).
Definition: ConstantRange.cpp:443
llvm::APIntOps::umax
const APInt & umax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be unsigned.
Definition: APInt.h:2133
llvm::ConstantRange::getSignedMax
APInt getSignedMax() const
Return the largest signed value contained in the ConstantRange.
Definition: ConstantRange.cpp:381
llvm::ConstantRange::getLower
const APInt & getLower() const
Return the lower value for this range.
Definition: ConstantRange.h:171
llvm::APInt::uadd_sat
APInt uadd_sat(const APInt &RHS) const
Definition: APInt.cpp:2013
std
Definition: BitVector.h:838
llvm::APInt::trunc
APInt trunc(unsigned width) const
Truncate to new width.
Definition: APInt.cpp:883
llvm::KnownBits
Definition: KnownBits.h:23
llvm::APInt::isMinSignedValue
bool isMinSignedValue() const
Determine if this is the smallest signed value.
Definition: APInt.h:408
llvm::APInt::clearSignBit
void clearSignBit()
Set the sign bit to 0.
Definition: APInt.h:1373
llvm::ConstantRange::smin
ConstantRange smin(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a signed minimum of a value in thi...
Definition: ConstantRange.cpp:1105
llvm::ConstantRange::getMinSignedBits
unsigned getMinSignedBits() const
Compute the maximal number of bits needed to represent every value in this signed range.
Definition: ConstantRange.cpp:427
Success
#define Success
Definition: AArch64Disassembler.cpp:260
llvm::ConstantRange::subWithNoWrap
ConstantRange subWithNoWrap(const ConstantRange &Other, unsigned NoWrapKind, PreferredRangeType RangeType=Smallest) const
Return a new range representing the possible values resulting from an subtraction with wrap type NoWr...
Definition: ConstantRange.cpp:973
llvm::BitWidth
constexpr unsigned BitWidth
Definition: BitmaskEnum.h:147
llvm::APInt::smul_ov
APInt smul_ov(const APInt &RHS, bool &Overflow) const
Definition: APInt.cpp:1952
llvm::ConstantRange::getActiveBits
unsigned getActiveBits() const
Compute the maximal number of active bits needed to represent every value in this range.
Definition: ConstantRange.cpp:420
llvm::ConstantRange::contains
bool contains(const APInt &Val) const
Return true if the specified value is in the set.
Definition: ConstantRange.cpp:393
llvm::CmpInst::ICMP_SGE
@ ICMP_SGE
signed greater or equal
Definition: InstrTypes.h:748
llvm::MCID::Add
@ Add
Definition: MCInstrDesc.h:183
llvm::countLeadingZeros
unsigned countLeadingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the most significant bit to the least stopping at the first 1.
Definition: MathExtras.h:225
llvm::ConstantRange::getSingleMissingElement
const APInt * getSingleMissingElement() const
If this set contains all but a single element, return it, otherwise return null.
Definition: ConstantRange.h:227
llvm::APInt::getSignedMinValue
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
Definition: APInt.h:199
llvm::ConstantRange
This class represents a range of values.
Definition: ConstantRange.h:47
llvm::APInt::sext
APInt sext(unsigned width) const
Sign extend to a new width.
Definition: APInt.cpp:928
llvm::ConstantRange::urem
ConstantRange urem(const ConstantRange &Other) const
Return a new range representing the possible values resulting from an unsigned remainder operation of...
Definition: ConstantRange.cpp:1238
llvm::ConstantRange::getNonEmpty
static ConstantRange getNonEmpty(APInt Lower, APInt Upper)
Create non-empty constant range with the given bounds.
Definition: ConstantRange.h:84
llvm::Instruction::BinaryOps
BinaryOps
Definition: Instruction.h:785
llvm::ConstantRange::binaryNot
ConstantRange binaryNot() const
Return a new range representing the possible values resulting from a binary-xor of a value in this ra...
Definition: ConstantRange.cpp:1311
llvm::HexagonMCInstrInfo::getMaxValue
int getMaxValue(MCInstrInfo const &MCII, MCInst const &MCI)
Return the maximum value of an extendable operand.
Definition: HexagonMCInstrInfo.cpp:346
llvm::ConstantRange::ashr
ConstantRange ashr(const ConstantRange &Other) const
Return a new range representing the possible values resulting from a arithmetic right shift of a valu...
Definition: ConstantRange.cpp:1408
llvm::ConstantRange::intersectWith
ConstantRange intersectWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the intersection of this range with another range.
Definition: ConstantRange.cpp:467
llvm::ConstantRange::fromKnownBits
static ConstantRange fromKnownBits(const KnownBits &Known, bool IsSigned)
Initialize a range based on a known bits constraint.
Definition: ConstantRange.cpp:58
llvm::CmpInst::ICMP_UGT
@ ICMP_UGT
unsigned greater than
Definition: InstrTypes.h:743
llvm::ConstantRange::signedAddMayOverflow
OverflowResult signedAddMayOverflow(const ConstantRange &Other) const
Return whether signed add of the two ranges always/never overflows.
Definition: ConstantRange.cpp:1615
llvm::APInt::countTrailingOnes
unsigned countTrailingOnes() const
Count the number of trailing one bits.
Definition: APInt.h:1550
llvm::max
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:340
llvm::APInt::getActiveBits
unsigned getActiveBits() const
Compute the number of active bits in the value.
Definition: APInt.h:1434
llvm::ConstantRange::print
void print(raw_ostream &OS) const
Print out the bounds to a stream.
Definition: ConstantRange.cpp:1711
llvm::ConstantRange::icmp
bool icmp(CmpInst::Predicate Pred, const ConstantRange &Other) const
Does the predicate Pred hold between ranges this and Other? NOTE: false does not mean that inverse pr...
Definition: ConstantRange.cpp:184
llvm::ConstantRange::usub_sat
ConstantRange usub_sat(const ConstantRange &Other) const
Perform an unsigned saturating subtraction of two constant ranges.
Definition: ConstantRange.cpp:1476
makeExactMulNUWRegion
static ConstantRange makeExactMulNUWRegion(const APInt &V)
Exact mul nuw region for single element RHS.
Definition: ConstantRange.cpp:190
llvm::ConstantRange::OverflowResult::NeverOverflows
@ NeverOverflows
Never overflows.
llvm::ConstantRange::makeExactICmpRegion
static ConstantRange makeExactICmpRegion(CmpInst::Predicate Pred, const APInt &Other)
Produce the exact range such that all values in the returned range satisfy the given predicate with a...
Definition: ConstantRange.cpp:138
llvm::HexagonMCInstrInfo::getMinValue
int getMinValue(MCInstrInfo const &MCII, MCInst const &MCI)
Return the minimum value of an extendable operand.
Definition: HexagonMCInstrInfo.cpp:357
llvm::ConstantRange::unsignedSubMayOverflow
OverflowResult unsignedSubMayOverflow(const ConstantRange &Other) const
Return whether unsigned sub of the two ranges always/never overflows.
Definition: ConstantRange.cpp:1645
llvm::APInt::sgt
bool sgt(const APInt &RHS) const
Signed greater than comparison.
Definition: APInt.h:1133
llvm::APInt::sadd_sat
APInt sadd_sat(const APInt &RHS) const
Definition: APInt.cpp:2003
llvm::APIntOps::RoundingUDiv
APInt RoundingUDiv(const APInt &A, const APInt &B, APInt::Rounding RM)
Return A unsign-divided by B, rounded by the given rounding mode.
Definition: APInt.cpp:2719
llvm::APInt::getLowBitsSet
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
Definition: APInt.h:289
llvm::ConstantRange::subtract
ConstantRange subtract(const APInt &CI) const
Subtract the specified constant from the endpoints of this constant range.
Definition: ConstantRange.cpp:435
llvm::ConstantRange::makeSatisfyingICmpRegion
static ConstantRange makeSatisfyingICmpRegion(CmpInst::Predicate Pred, const ConstantRange &Other)
Produce the largest range such that all values in the returned range satisfy the given predicate with...
Definition: ConstantRange.cpp:128
llvm::KnownBits::getBitWidth
unsigned getBitWidth() const
Get the bit width of this value.
Definition: KnownBits.h:40
llvm::APInt::getBitsSetFrom
static APInt getBitsSetFrom(unsigned numBits, unsigned loBit)
Constructs an APInt value that has a contiguous range of bits set.
Definition: APInt.h:269
llvm::ConstantRange::isEmptySet
bool isEmptySet() const
Return true if this set contains no members.
Definition: ConstantRange.cpp:313
llvm::ConstantRange::sextOrTrunc
ConstantRange sextOrTrunc(uint32_t BitWidth) const
Make this range have the bit width given by BitWidth.
Definition: ConstantRange.cpp:787
raw_ostream.h
llvm::abs
APFloat abs(APFloat X)
Returns the absolute value of the argument.
Definition: APFloat.h:1282
llvm::ConstantRange::getUpper
const APInt & getUpper() const
Return the upper value for this range.
Definition: ConstantRange.h:174
llvm::RecurKind::SMax
@ SMax
Signed integer max implemented in terms of select(cmp()).
isNonNegative
static bool isNonNegative(Value *V, LazyValueInfo *LVI, Instruction *CxtI)
Definition: CorrelatedValuePropagation.cpp:646
Debug.h
llvm::APIntOps::smax
const APInt & smax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be signed.
Definition: APInt.h:2123
llvm::ConstantRange::umin
ConstantRange umin(const ConstantRange &Other) const
Return a new range representing the possible values resulting from an unsigned minimum of a value in ...
Definition: ConstantRange.cpp:1119
llvm::ConstantRange::OverflowResult::MayOverflow
@ MayOverflow
May or may not overflow.
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1184
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:37
llvm::ConstantRange::makeExactNoWrapRegion
static ConstantRange makeExactNoWrapRegion(Instruction::BinaryOps BinOp, const APInt &Other, unsigned NoWrapKind)
Produce the range that contains X if and only if "X BinOp Other" does not wrap.
Definition: ConstantRange.cpp:301