[PATCH] D49276: [InstCombine] Corrections in comments for division transformation

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 15 10:12:07 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL337131: [InstCombine] Corrections in comments for division transformation (NFC) (authored by spatel, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D49276

Files:
  llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp


Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -628,7 +628,7 @@
   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,15 +714,15 @@
       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));
         BO->setIsExact(I.isExact());
         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));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49276.155587.patch
Type: text/x-patch
Size: 1550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180715/fa21b468/attachment.bin>


More information about the llvm-commits mailing list