summaryrefslogtreecommitdiffstats
path: root/include/llvm/Support
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-09-27 06:38:05 +0000
committerChris Lattner <sabre@nondot.org>2005-09-27 06:38:05 +0000
commit09f00b1295f8204117a12e075aa062eed08905ec (patch)
treef52b31944e0e8853537f2c35bbc7f79b2db8808e /include/llvm/Support
parentdf0ef1d0fe336de8ffca08e222cf22ada276a7da (diff)
downloadexternal_llvm-09f00b1295f8204117a12e075aa062eed08905ec.zip
external_llvm-09f00b1295f8204117a12e075aa062eed08905ec.tar.gz
external_llvm-09f00b1295f8204117a12e075aa062eed08905ec.tar.bz2
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
Diffstat (limited to 'include/llvm/Support')
-rw-r--r--include/llvm/Support/PatternMatch.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h
index 0be4cd9..9a225df 100644
--- a/include/llvm/Support/PatternMatch.h
+++ b/include/llvm/Support/PatternMatch.h
@@ -71,7 +71,8 @@ inline bind_ty<ConstantInt> m_ConstantInt(ConstantInt *&CI) { return CI; }
// Matchers for specific binary operators
//
-template<typename LHS_t, typename RHS_t, unsigned Opcode>
+template<typename LHS_t, typename RHS_t,
+ unsigned Opcode, typename ConcreteTy = BinaryOperator>
struct BinaryOp_match {
LHS_t L;
RHS_t R;
@@ -80,9 +81,11 @@ struct BinaryOp_match {
template<typename OpTy>
bool match(OpTy *V) {
- if (Instruction *I = dyn_cast<Instruction>(V))
+ if (V->getValueType() == Value::InstructionVal + Opcode) {
+ ConcreteTy *I = cast<ConcreteTy>(V);
return I->getOpcode() == Opcode && L.match(I->getOperand(0)) &&
R.match(I->getOperand(1));
+ }
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
return CE->getOpcode() == Opcode && L.match(CE->getOperand(0)) &&
R.match(CE->getOperand(1));
@@ -139,15 +142,15 @@ inline BinaryOp_match<LHS, RHS, Instruction::Xor> m_Xor(const LHS &L,
}
template<typename LHS, typename RHS>
-inline BinaryOp_match<LHS, RHS, Instruction::Shl> m_Shl(const LHS &L,
- const RHS &R) {
- return BinaryOp_match<LHS, RHS, Instruction::Shl>(L, R);
+inline BinaryOp_match<LHS, RHS, Instruction::Shl,
+ ShiftInst> m_Shl(const LHS &L, const RHS &R) {
+ return BinaryOp_match<LHS, RHS, Instruction::Shl, ShiftInst>(L, R);
}
template<typename LHS, typename RHS>
-inline BinaryOp_match<LHS, RHS, Instruction::Shr> m_Shr(const LHS &L,
- const RHS &R) {
- return BinaryOp_match<LHS, RHS, Instruction::Shr>(L, R);
+inline BinaryOp_match<LHS, RHS, Instruction::Shr,
+ ShiftInst> m_Shr(const LHS &L, const RHS &R) {
+ return BinaryOp_match<LHS, RHS, Instruction::Shr, ShiftInst>(L, R);
}
//===----------------------------------------------------------------------===//