Skip to content

Commit

Permalink
[Support][CodeGen] Fix spelling Divison->Division. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
topperc committed Jul 18, 2022
1 parent 795602a commit a55ff6a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
8 changes: 4 additions & 4 deletions llvm/include/llvm/Support/DivisionByConstantInfo.h
@@ -1,4 +1,4 @@
//== llvm/Support/DivisonByConstantInfo.h - division by constant -*- C++ -*-==//
//===- llvm/Support/DivisionByConstantInfo.h ---------------------*- C++ -*-==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand All @@ -25,9 +25,9 @@ struct SignedDivisionByConstantInfo {
};

/// Magic data for optimising unsigned division by a constant.
struct UnsignedDivisonByConstantInfo {
static UnsignedDivisonByConstantInfo get(const APInt &D,
unsigned LeadingZeros = 0);
struct UnsignedDivisionByConstantInfo {
static UnsignedDivisionByConstantInfo get(const APInt &D,
unsigned LeadingZeros = 0);
APInt Magic; ///< magic number
bool IsAdd; ///< add indicator
unsigned ShiftAmount; ///< shift amount
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
Expand Up @@ -4800,8 +4800,8 @@ MachineInstr *CombinerHelper::buildUDivUsingMul(MachineInstr &MI) {
auto BuildUDIVPattern = [&](const Constant *C) {
auto *CI = cast<ConstantInt>(C);
const APInt &Divisor = CI->getValue();
UnsignedDivisonByConstantInfo magics =
UnsignedDivisonByConstantInfo::get(Divisor);
UnsignedDivisionByConstantInfo magics =
UnsignedDivisionByConstantInfo::get(Divisor);
unsigned PreShift = 0, PostShift = 0;

// If the divisor is even, we can avoid using the expensive fixup by
Expand All @@ -4810,7 +4810,7 @@ MachineInstr *CombinerHelper::buildUDivUsingMul(MachineInstr &MI) {
PreShift = Divisor.countTrailingZeros();
// Get magic number for the shifted divisor.
magics =
UnsignedDivisonByConstantInfo::get(Divisor.lshr(PreShift), PreShift);
UnsignedDivisionByConstantInfo::get(Divisor.lshr(PreShift), PreShift);
assert(!magics.IsAdd && "Should use cheap fixup now");
}

Expand Down
6 changes: 4 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Expand Up @@ -5905,15 +5905,17 @@ SDValue TargetLowering::BuildUDIV(SDNode *N, SelectionDAG &DAG,
// FIXME: We should use a narrower constant when the upper
// bits are known to be zero.
const APInt& Divisor = C->getAPIntValue();
UnsignedDivisonByConstantInfo magics = UnsignedDivisonByConstantInfo::get(Divisor);
UnsignedDivisionByConstantInfo magics =
UnsignedDivisionByConstantInfo::get(Divisor);
unsigned PreShift = 0, PostShift = 0;

// If the divisor is even, we can avoid using the expensive fixup by
// shifting the divided value upfront.
if (magics.IsAdd && !Divisor[0]) {
PreShift = Divisor.countTrailingZeros();
// Get magic number for the shifted divisor.
magics = UnsignedDivisonByConstantInfo::get(Divisor.lshr(PreShift), PreShift);
magics =
UnsignedDivisionByConstantInfo::get(Divisor.lshr(PreShift), PreShift);
assert(!magics.IsAdd && "Should use cheap fixup now");
}

Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Support/DivisionByConstantInfo.cpp
@@ -1,4 +1,4 @@
//===----- DivisonByConstantInfo.cpp - division by constant -*- C++ -*-----===//
//===----- DivisionByConstantInfo.cpp - division by constant -*- C++ -*----===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down Expand Up @@ -62,11 +62,11 @@ SignedDivisionByConstantInfo SignedDivisionByConstantInfo::get(const APInt &D) {
/// S. Warren, Jr., chapter 10.
/// LeadingZeros can be used to simplify the calculation if the upper bits
/// of the divided value are known zero.
UnsignedDivisonByConstantInfo
UnsignedDivisonByConstantInfo::get(const APInt &D, unsigned LeadingZeros) {
UnsignedDivisionByConstantInfo
UnsignedDivisionByConstantInfo::get(const APInt &D, unsigned LeadingZeros) {
unsigned P;
APInt NC, Delta, Q1, R1, Q2, R2;
struct UnsignedDivisonByConstantInfo Retval;
struct UnsignedDivisionByConstantInfo Retval;
Retval.IsAdd = false; // initialize "add" indicator
APInt AllOnes = APInt::getAllOnes(D.getBitWidth()).lshr(LeadingZeros);
APInt SignedMin = APInt::getSignedMinValue(D.getBitWidth());
Expand Down

0 comments on commit a55ff6a

Please sign in to comment.