summaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine/InstCombineShifts.cpp
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2013-02-01 06:45:40 +0000
committerNadav Rotem <nrotem@apple.com>2013-02-01 06:45:40 +0000
commitd5eb1cbee55b60dd7a5745f47c0b46a3a0b952e3 (patch)
tree183682d4c346550926616a97caccf702f8bf4454 /lib/Transforms/InstCombine/InstCombineShifts.cpp
parentf1f57c5c1a53cfcb0de23660a4d607ed57e0525a (diff)
downloadllvm-d5eb1cbee55b60dd7a5745f47c0b46a3a0b952e3.tar.gz
llvm-d5eb1cbee55b60dd7a5745f47c0b46a3a0b952e3.tar.bz2
llvm-d5eb1cbee55b60dd7a5745f47c0b46a3a0b952e3.tar.xz
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/InstCombine/InstCombineShifts.cpp')
-rw-r--r--lib/Transforms/InstCombine/InstCombineShifts.cpp6
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;
}