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 assert(!
D.isZero() && !
D.isOne() &&
"Precondition violation.");
77 assert(
D.getBitWidth() > 1 &&
"Does not work at smaller bitwidths.");
89 assert(
NC.urem(
D) ==
D - 1 &&
"Unexpected NC value");
90 unsigned P =
D.getBitWidth() - 1;
98 if (R1.
uge(
NC - R1)) {
109 if ((
R2 + 1).uge(
D -
R2)) {
110 if (Q2.
uge(SignedMax))
120 if (Q2.
uge(SignedMin))
132 }
while (
P <
D.getBitWidth() * 2 &&
133 (Q1.
ult(Delta) || (Q1 == Delta && R1.
isZero())));
135 if (Retval.
IsAdd && !
D[0] && AllowEvenDivisorOptimization) {
145 Retval.
Magic = std::move(Q2);
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Class for arbitrary precision integers.
static void udivrem(const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder)
Dual division/remainder interface.
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.
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 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
static UnsignedDivisionByConstantInfo get(const APInt &D, unsigned LeadingZeros=0, bool AllowEvenDivisorOptimization=true)
Calculate the magic numbers required to implement an unsigned integer division by a constant as a seq...
unsigned PostShift
post-shift amount