LLVM 20.0.0git
Static Public Member Functions | Public Attributes | List of all members
llvm::UnsignedDivisionByConstantInfo Struct Reference

Magic data for optimising unsigned division by a constant. More...

#include "llvm/Support/DivisionByConstantInfo.h"

Static Public Member Functions

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 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
 

Detailed Description

Magic data for optimising unsigned division by a constant.

Definition at line 28 of file DivisionByConstantInfo.h.

Member Function Documentation

◆ get()

UnsignedDivisionByConstantInfo UnsignedDivisionByConstantInfo::get ( const APInt D,
unsigned  LeadingZeros = 0,
bool  AllowEvenDivisorOptimization = true 
)
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::buildUDivUsingMul(), and get().

Member Data Documentation

◆ IsAdd

bool llvm::UnsignedDivisionByConstantInfo::IsAdd

◆ Magic

APInt llvm::UnsignedDivisionByConstantInfo::Magic

◆ PostShift

unsigned llvm::UnsignedDivisionByConstantInfo::PostShift

post-shift amount

Definition at line 34 of file DivisionByConstantInfo.h.

Referenced by llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivUsingMul(), and get().

◆ PreShift

unsigned llvm::UnsignedDivisionByConstantInfo::PreShift

pre-shift amount

Definition at line 35 of file DivisionByConstantInfo.h.

Referenced by llvm::TargetLowering::BuildUDIV(), llvm::CombinerHelper::buildUDivUsingMul(), and get().


The documentation for this struct was generated from the following files: