[llvm] ab372cd - [InstCombine] add code comment for icmp transform; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 1 05:23:12 PDT 2022


Author: Sanjay Patel
Date: 2022-07-01T08:21:55-04:00
New Revision: ab372cdd6ff4e6ccb1fdd83a421914cddfb30e58

URL: https://github.com/llvm/llvm-project/commit/ab372cdd6ff4e6ccb1fdd83a421914cddfb30e58
DIFF: https://github.com/llvm/llvm-project/commit/ab372cdd6ff4e6ccb1fdd83a421914cddfb30e58.diff

LOG: [InstCombine] add code comment for icmp transform; NFC

This was accidentally left out of cc88445a9106

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index a75cc41c2fed..d1f89973caa1 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1551,6 +1551,8 @@ Instruction *InstCombinerImpl::foldICmpTruncConstant(ICmpInst &Cmp,
   unsigned DstBits = Trunc->getType()->getScalarSizeInBits(),
            SrcBits = X->getType()->getScalarSizeInBits();
   if (Cmp.isEquality() && Trunc->hasOneUse()) {
+    // Canonicalize to a mask and wider compare if the wide type is suitable:
+    // (trunc X to i8) == C --> (X & 0xff) == (zext C)
     if (!X->getType()->isVectorTy() && shouldChangeType(DstBits, SrcBits)) {
       Constant *Mask = ConstantInt::get(X->getType(),
                                         APInt::getLowBitsSet(SrcBits, DstBits));


        


More information about the llvm-commits mailing list