OSDN Git Service

[InstCombine] Replace an equality compare of two APInt pointers with a compare of...
authorCraig Topper <craig.topper@intel.com>
Tue, 3 Oct 2017 04:55:04 +0000 (04:55 +0000)
committerCraig Topper <craig.topper@intel.com>
Tue, 3 Oct 2017 04:55:04 +0000 (04:55 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314761 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineCompares.cpp

index c548445..d3d9b5e 100644 (file)
@@ -2629,7 +2629,7 @@ Instruction *InstCombiner::foldICmpBinOpEqualityWithConstant(ICmpInst &Cmp,
     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()));