Fix m_Not and m_Neg to not match random ConstantInt's. Before
authorChris Lattner <sabre@nondot.org>
Sat, 15 Jan 2011 05:52:27 +0000 (05:52 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 15 Jan 2011 05:52:27 +0000 (05:52 +0000)
these would try hard to match constants by inverting the bits
and recursively matching.  There are two problems with this:
1) some patterns would match when we didn't want them to (theoretical)
2) this is insanely expensive to do, and most often pointless.

This was apparently useful in just 2 instcombine cases, which I
added code to handle explicitly.  This change speeds up 'opt'
time on 176.gcc by 1% and produces bitwise identical code.

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

include/llvm/Support/PatternMatch.h

index 8b5812141df91c48d2fb825660f4cb42f2876608..322ed436c9fb31d3d1bc4aba986c82ee19245c37 100644 (file)
@@ -521,8 +521,6 @@ struct not_match {
     if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
       if (CE->getOpcode() == Instruction::Xor)
         return matchIfNot(CE->getOperand(0), CE->getOperand(1));
-    if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
-      return L.match(ConstantExpr::getNot(CI));
     return false;
   }
 private:
@@ -557,8 +555,6 @@ struct neg_match {
     if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
       if (CE->getOpcode() == Instruction::Sub)
         return matchIfNeg(CE->getOperand(0), CE->getOperand(1));
-    if (ConstantInt *CI = dyn_cast<ConstantInt>(V))
-      return L.match(ConstantExpr::getNeg(CI));
     return false;
   }
 private: