LLVM 22.0.0git
llvm::UnsignedDivisionByConstantInfo Struct Reference

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

Detailed Description

Magic data for optimising unsigned division by a constant.

Definition at line 29 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::buildUDivOrURemUsingMul(), and get().

Member Data Documentation

◆ IsAdd

bool llvm::UnsignedDivisionByConstantInfo::IsAdd

◆ Magic

APInt llvm::UnsignedDivisionByConstantInfo::Magic

◆ PostShift

unsigned llvm::UnsignedDivisionByConstantInfo::PostShift

◆ PreShift

unsigned llvm::UnsignedDivisionByConstantInfo::PreShift

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