From 09f00b1295f8204117a12e075aa062eed08905ec Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 27 Sep 2005 06:38:05 +0000 Subject: [PATCH] Make this slightly more efficient by pushing actual type information down into the evaluator. This shrinks a release build of instcombine's text section from 216363 to 215975 bytes (on PPC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23468 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/PatternMatch.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h index 0be4cd97b5d..9a225dfeab5 100644 --- a/include/llvm/Support/PatternMatch.h +++ b/include/llvm/Support/PatternMatch.h @@ -71,7 +71,8 @@ inline bind_ty m_ConstantInt(ConstantInt *&CI) { return CI; } // Matchers for specific binary operators // -template +template struct BinaryOp_match { LHS_t L; RHS_t R; @@ -80,9 +81,11 @@ struct BinaryOp_match { template bool match(OpTy *V) { - if (Instruction *I = dyn_cast(V)) + if (V->getValueType() == Value::InstructionVal + Opcode) { + ConcreteTy *I = cast(V); return I->getOpcode() == Opcode && L.match(I->getOperand(0)) && R.match(I->getOperand(1)); + } if (ConstantExpr *CE = dyn_cast(V)) return CE->getOpcode() == Opcode && L.match(CE->getOperand(0)) && R.match(CE->getOperand(1)); @@ -139,15 +142,15 @@ inline BinaryOp_match m_Xor(const LHS &L, } template -inline BinaryOp_match m_Shl(const LHS &L, - const RHS &R) { - return BinaryOp_match(L, R); +inline BinaryOp_match m_Shl(const LHS &L, const RHS &R) { + return BinaryOp_match(L, R); } template -inline BinaryOp_match m_Shr(const LHS &L, - const RHS &R) { - return BinaryOp_match(L, R); +inline BinaryOp_match m_Shr(const LHS &L, const RHS &R) { + return BinaryOp_match(L, R); } //===----------------------------------------------------------------------===// -- 2.34.1