22 assert(!
D.isZero() &&
"Precondition violation.");
25 assert(
D.getBitWidth() >= 3 &&
"Does not work at smaller bitwidths.");
32 APInt T = SignedMin + (
D.lshr(
D.getBitWidth() - 1));
34 unsigned P =
D.getBitWidth() - 1;
57 }
while (Q1.
ult(Delta) || (Q1 == Delta && R1.
isZero()));
59 Retval.
Magic = std::move(Q2);
75 bool AllowEvenDivisorOptimization,
76 bool AllowWidenOptimization) {
77 assert(!
D.isZero() && !
D.isOne() &&
"Precondition violation.");
78 assert(
D.getBitWidth() > 1 &&
"Does not work at smaller bitwidths.");
91 assert(
NC.urem(
D) ==
D - 1 &&
"Unexpected NC value");
92 unsigned P =
D.getBitWidth() - 1;
100 if (R1.
uge(
NC - R1)) {
111 if ((
R2 + 1).uge(
D -
R2)) {
112 if (Q2.
uge(SignedMax))
122 if (Q2.
uge(SignedMin))
134 }
while (
P <
D.getBitWidth() * 2 &&
135 (Q1.
ult(Delta) || (Q1 == Delta && R1.
isZero())));
137 if (Retval.
IsAdd && !
D[0] && AllowEvenDivisorOptimization) {
147 Retval.
Magic = std::move(Q2);
161 if (Retval.
IsAdd && AllowWidenOptimization) {
162 unsigned W =
D.getBitWidth();
163 unsigned OriginalShift = Retval.
PostShift + W + 1;
166 .shl(W * 2 - OriginalShift);
167 Retval.
IsAdd =
false;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Class for arbitrary precision integers.
static LLVM_ABI void udivrem(const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder)
Dual division/remainder interface.
LLVM_ABI APInt zext(unsigned width) const
Zero extend to a new width.
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
bool ult(const APInt &RHS) const
Unsigned less than comparison.
static APInt getSignedMaxValue(unsigned numBits)
Gets maximum signed value of APInt for a specific bit width.
void negate()
Negate this APInt in place.
static APInt getSignedMinValue(unsigned numBits)
Gets minimum signed value of APInt for a specific bit width.
APInt shl(unsigned shiftAmt) const
Left-shift function.
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Constructs an APInt value that has the bottom loBitsSet bits set.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
This is an optimization pass for GlobalISel generic memory operations.
Magic data for optimising signed division by a constant.
unsigned ShiftAmount
shift amount
static LLVM_ABI SignedDivisionByConstantInfo get(const APInt &D)
Calculate the magic numbers required to implement a signed integer division by a constant as a sequen...
Magic data for optimising unsigned division by a constant.
unsigned PreShift
pre-shift amount
unsigned PostShift
post-shift amount
static LLVM_ABI UnsignedDivisionByConstantInfo get(const APInt &D, unsigned LeadingZeros=0, bool AllowEvenDivisorOptimization=true, bool AllowWidenOptimization=false)
Calculate the magic numbers required to implement an unsigned integer division by a constant as a seq...
bool Widen
use widen optimization