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

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

#include "llvm/Support/DivisionByConstantInfo.h"

Collaboration diagram for llvm::UnsignedDivisonByConstantInfo:
Collaboration graph
[legend]

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

Detailed Description

Magic data for optimising unsigned division by a constant.

Definition at line 28 of file DivisionByConstantInfo.h.

Member Function Documentation

◆ get()

UnsignedDivisonByConstantInfo UnsignedDivisonByConstantInfo::get ( const APInt D,
unsigned  LeadingZeros = 0 
)
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().

Member Data Documentation

◆ IsAdd

bool llvm::UnsignedDivisonByConstantInfo::IsAdd

◆ Magic

APInt llvm::UnsignedDivisonByConstantInfo::Magic

◆ ShiftAmount

unsigned llvm::UnsignedDivisonByConstantInfo::ShiftAmount

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