[llvm] r337131 - [InstCombine] Corrections in comments for division transformation (NFC)
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 15 10:06:59 PDT 2018
Author: spatel
Date: Sun Jul 15 10:06:59 2018
New Revision: 337131
URL: http://llvm.org/viewvc/llvm-project?rev=337131&view=rev
Log:
[InstCombine] Corrections in comments for division transformation (NFC)
The actual code seems to be correct, but the comments were misleading.
Patch by Aaron Puchert!
Differential Revision: https://reviews.llvm.org/D49276
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=337131&r1=337130&r2=337131&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Sun Jul 15 10:06:59 2018
@@ -628,7 +628,7 @@ static bool multiplyOverflows(const APIn
return Overflow;
}
-/// True if C2 is a multiple of C1. Quotient contains C2/C1.
+/// True if C1 is a multiple of C2. Quotient contains C1/C2.
static bool isMultiple(const APInt &C1, const APInt &C2, APInt &Quotient,
bool IsSigned) {
assert(C1.getBitWidth() == C2.getBitWidth() && "Constant widths not equal");
@@ -714,7 +714,7 @@ Instruction *InstCombiner::commonIDivTra
APInt C1Shifted = APInt::getOneBitSet(
C1->getBitWidth(), static_cast<unsigned>(C1->getLimitedValue()));
- // (X << C1) / C2 -> X / (C2 >> C1) if C2 is a multiple of C1.
+ // (X << C1) / C2 -> X / (C2 >> C1) if C2 is a multiple of 1 << C1.
if (isMultiple(*C2, C1Shifted, Quotient, IsSigned)) {
auto *BO = BinaryOperator::Create(I.getOpcode(), X,
ConstantInt::get(Ty, Quotient));
@@ -722,7 +722,7 @@ Instruction *InstCombiner::commonIDivTra
return BO;
}
- // (X << C1) / C2 -> X * (C2 >> C1) if C1 is a multiple of C2.
+ // (X << C1) / C2 -> X * ((1 << C1) / C2) if 1 << C1 is a multiple of C2.
if (isMultiple(C1Shifted, *C2, Quotient, IsSigned)) {
auto *Mul = BinaryOperator::Create(Instruction::Mul, X,
ConstantInt::get(Ty, Quotient));
More information about the llvm-commits
mailing list