diff options
author | Chris Lattner <sabre@nondot.org> | 2010-01-01 22:12:03 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-01-01 22:12:03 +0000 |
commit | 33767185055399d729e2a1b2c24d4d36efab125c (patch) | |
tree | 8f145a3ae628f9d5ff73fc5e151c6938f24970fa /lib/Transforms/Scalar/InstructionCombining.cpp | |
parent | e33d41315240541aa50bd61e434af8d8998b4f92 (diff) |
use 'match' to simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92400 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index c6a8df44c8..ee0b9374cb 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -2949,12 +2949,11 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { // Optimize pointer differences into the same array into a size. Consider: // &A[10] - &A[0]: we should compile this to "10". if (TD) { - if (PtrToIntInst *LHS = dyn_cast<PtrToIntInst>(Op0)) - if (PtrToIntInst *RHS = dyn_cast<PtrToIntInst>(Op1)) - if (Value *Res = OptimizePointerDifference(LHS->getOperand(0), - RHS->getOperand(0), - I.getType())) - return ReplaceInstUsesWith(I, Res); + Value *LHSOp, *RHSOp; + if (match(Op0, m_Cast<PtrToIntInst>(m_Value(LHSOp))) && + match(Op1, m_Cast<PtrToIntInst>(m_Value(RHSOp)))) + if (Value *Res = OptimizePointerDifference(LHSOp, RHSOp, I.getType())) + return ReplaceInstUsesWith(I, Res); // trunc(p)-trunc(q) -> trunc(p-q) if (TruncInst *LHST = dyn_cast<TruncInst>(Op0)) |