diff options
author | Nadav Rotem <nrotem@apple.com> | 2013-02-01 06:45:40 +0000 |
---|---|---|
committer | Nadav Rotem <nrotem@apple.com> | 2013-02-01 06:45:40 +0000 |
commit | d5eb1cbee55b60dd7a5745f47c0b46a3a0b952e3 (patch) | |
tree | 183682d4c346550926616a97caccf702f8bf4454 /lib/Transforms | |
parent | f1f57c5c1a53cfcb0de23660a4d607ed57e0525a (diff) |
Optimize shift lefts of a constant by a value plus constant into a single shift.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174152 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineShifts.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineShifts.cpp b/lib/Transforms/InstCombine/InstCombineShifts.cpp index 8cf76e5e8a..f9e94f225f 100644 --- a/lib/Transforms/InstCombine/InstCombineShifts.cpp +++ b/lib/Transforms/InstCombine/InstCombineShifts.cpp @@ -709,6 +709,12 @@ Instruction *InstCombiner::visitShl(BinaryOperator &I) { match(I.getOperand(1), m_Constant(C2))) return BinaryOperator::CreateShl(ConstantExpr::getShl(C1, C2), A); + // shl (c1 , add(y , c2)) -> (shl (shl(c1, c2)), y) + if (match(I.getOperand(0), m_Constant(C1)) && + match(I.getOperand(1), m_Add(m_Value(A), m_Constant(C2)))) { + return BinaryOperator::CreateShl(ConstantExpr::getShl(C1, C2), A); + } + return 0; } |