LLVM
15.0.0git
|
Magic data for optimising unsigned division by a constant. More...
#include "llvm/Support/DivisionByConstantInfo.h"
Static Public Member Functions | |
static UnsignedDivisonByConstantInfo | get (const APInt &D, unsigned LeadingZeros=0) |
Calculate the magic numbers required to implement an unsigned integer division by a constant as a sequence of multiplies, adds and shifts. More... | |
Public Attributes | |
APInt | Magic |
magic number More... | |
bool | IsAdd |
add indicator More... | |
unsigned | ShiftAmount |
shift amount More... | |
Magic data for optimising unsigned division by a constant.
Definition at line 28 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 66 of file DivisionByConstantInfo.cpp.
References D, llvm::APInt::getAllOnes(), llvm::APInt::getSignedMaxValue(), llvm::APInt::getSignedMinValue(), IsAdd, llvm::APInt::lshr(), Magic, NC, P, R2, ShiftAmount, llvm::APInt::udiv(), llvm::APInt::uge(), and llvm::APInt::ult().
Referenced by llvm::TargetLowering::BuildUDIV(), and llvm::CombinerHelper::buildUDivUsingMul().
bool llvm::UnsignedDivisonByConstantInfo::IsAdd |
add indicator
Definition at line 32 of file DivisionByConstantInfo.h.
Referenced by llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivUsingMul(), and get().
APInt llvm::UnsignedDivisonByConstantInfo::Magic |
magic number
Definition at line 31 of file DivisionByConstantInfo.h.
Referenced by llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivUsingMul(), and get().
unsigned llvm::UnsignedDivisonByConstantInfo::ShiftAmount |
shift amount
Definition at line 33 of file DivisionByConstantInfo.h.
Referenced by llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivUsingMul(), and get().