[llvm] r314761 - [InstCombine] Replace an equality compare of two APInt pointers with a compare of the APInts themselves.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 21:55:04 PDT 2017


Author: ctopper
Date: Mon Oct  2 21:55:04 2017
New Revision: 314761

URL: http://llvm.org/viewvc/llvm-project?rev=314761&view=rev
Log:
[InstCombine] Replace an equality compare of two APInt pointers with a compare of the APInts themselves.

Apparently this works by virtue of the fact that the pointers are pointers to the APInts stored inside of the ConstantInt objects. But I really don't think we should be relying on that.

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

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=314761&r1=314760&r2=314761&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Oct  2 21:55:04 2017
@@ -2629,7 +2629,7 @@ Instruction *InstCombiner::foldICmpBinOp
     const APInt *BOC;
     if (match(BOp1, m_APInt(BOC))) {
       // If we have ((X & C) == C), turn it into ((X & C) != 0).
-      if (C == BOC && C->isPowerOf2())
+      if (*C == *BOC && C->isPowerOf2())
         return new ICmpInst(isICMP_NE ? ICmpInst::ICMP_EQ : ICmpInst::ICMP_NE,
                             BO, Constant::getNullValue(RHS->getType()));
 




More information about the llvm-commits mailing list