[InstCombine] add code comment for icmp transform; NFC
authorSanjay Patel <spatel@rotateright.com>
Fri, 1 Jul 2022 12:21:55 +0000 (08:21 -0400)
committerSanjay Patel <spatel@rotateright.com>
Fri, 1 Jul 2022 12:21:55 +0000 (08:21 -0400)
This was accidentally left out of cc88445a9106

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

index a75cc41..d1f8997 100644 (file)
@@ -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));