diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-02-10 21:46:09 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-02-10 21:46:09 +0000 |
commit | 19495198af50959c52cfbcac9c21a2e670c43fc9 (patch) | |
tree | 74be8bf13ed723291aa236756e235cf9c3b5e5f8 /llvm/lib | |
parent | 51a6fc6fec60b0b16a3b3478c589b780af339f41 (diff) | |
download | bcm5719-llvm-19495198af50959c52cfbcac9c21a2e670c43fc9.tar.gz bcm5719-llvm-19495198af50959c52cfbcac9c21a2e670c43fc9.zip |
[InstCombine] Add constant vector support for ~(C >> Y) --> ~C >> Y
Includes adding m_NonNegative constant pattern matcher
llvm-svn: 324825
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 4b3a58126d5..2f4e97cb92a 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -2284,16 +2284,18 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { // the 'not' by inverting the constant and using the opposite shift type. // Canonicalization rules ensure that only a negative constant uses 'ashr', // but we must check that in case that transform has not fired yet. - const APInt *C; - if (match(NotVal, m_AShr(m_APInt(C), m_Value(Y))) && C->isNegative()) { + Constant *C; + if (match(NotVal, m_AShr(m_Constant(C), m_Value(Y))) && + match(C, m_Negative())) { // ~(C >>s Y) --> ~C >>u Y (when inverting the replicated sign bits) - Constant *NotC = ConstantInt::get(I.getType(), ~(*C)); + Constant *NotC = ConstantExpr::getNot(C); return BinaryOperator::CreateLShr(NotC, Y); } - if (match(NotVal, m_LShr(m_APInt(C), m_Value(Y))) && C->isNonNegative()) { + if (match(NotVal, m_LShr(m_Constant(C), m_Value(Y))) && + match(C, m_NonNegative())) { // ~(C >>u Y) --> ~C >>s Y (when inverting the replicated sign bits) - Constant *NotC = ConstantInt::get(I.getType(), ~(*C)); + Constant *NotC = ConstantExpr::getNot(C); return BinaryOperator::CreateAShr(NotC, Y); } } |