diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-04-29 08:15:41 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-04-29 08:15:41 +0000 |
commit | 16f18ed7b555bce5163f3faafc3da36e4d285897 (patch) | |
tree | f56ea88a50bf310cb06e4731d35ea40af573f216 /llvm/lib | |
parent | 0593f5329557a24dbc0c57d225df2fbd75a95793 (diff) | |
download | bcm5719-llvm-16f18ed7b555bce5163f3faafc3da36e4d285897.tar.gz bcm5719-llvm-16f18ed7b555bce5163f3faafc3da36e4d285897.zip |
InstCombine: turn (C1 << A) << C2) into (C1 << C2) << A)
Fixes PR9809.
llvm-svn: 130485
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp index a7f800587bb..8143b257b30 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp @@ -644,7 +644,14 @@ Instruction *InstCombiner::visitShl(BinaryOperator &I) { return &I; } } - + + // (C1 << A) << C2) -> (C1 << C2) << A) + Constant *C1, *C2; + Value *A; + if (match(I.getOperand(0), m_OneUse(m_Shl(m_Constant(C1), m_Value(A)))) && + match(I.getOperand(1), m_Constant(C2))) + return BinaryOperator::CreateShl(ConstantExpr::getShl(C1, C2), A); + return 0; } |