LLVM 22.0.0git
|
Magic data for optimising unsigned division by a constant. More...
#include "llvm/Support/DivisionByConstantInfo.h"
Static Public Member Functions | |
static LLVM_ABI 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 sequence of multiplies, adds and shifts. |
Public Attributes | |
APInt | Magic |
magic number | |
bool | IsAdd |
add indicator | |
unsigned | PostShift |
post-shift amount | |
unsigned | PreShift |
pre-shift amount |
Magic data for optimising unsigned division by a constant.
Definition at line 29 of file DivisionByConstantInfo.h.
|
static |
Calculate the magic numbers required to implement an unsigned integer division by a constant as a sequence of multiplies, adds and shifts.
Requires that the divisor not be 0. Taken from "Hacker's Delight", Henry S. Warren, Jr., chapter 10. LeadingZeros can be used to simplify the calculation if the upper bits of the divided value are known zero.
Definition at line 74 of file DivisionByConstantInfo.cpp.
References llvm::AllOnes, assert(), D(), get(), llvm::APInt::getLowBitsSet(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), IsAdd, llvm::APInt::isZero(), Magic, NC, P, PostShift, PreShift, R2, llvm::APInt::udivrem(), llvm::APInt::uge(), and llvm::APInt::ult().
Referenced by llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivOrURemUsingMul(), and get().
bool llvm::UnsignedDivisionByConstantInfo::IsAdd |
add indicator
Definition at line 34 of file DivisionByConstantInfo.h.
Referenced by llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivOrURemUsingMul(), and get().
APInt llvm::UnsignedDivisionByConstantInfo::Magic |
magic number
Definition at line 33 of file DivisionByConstantInfo.h.
Referenced by llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivOrURemUsingMul(), and get().
unsigned llvm::UnsignedDivisionByConstantInfo::PostShift |
post-shift amount
Definition at line 35 of file DivisionByConstantInfo.h.
Referenced by llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivOrURemUsingMul(), and get().
unsigned llvm::UnsignedDivisionByConstantInfo::PreShift |
pre-shift amount
Definition at line 36 of file DivisionByConstantInfo.h.
Referenced by llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivOrURemUsingMul(), and get().