diff options
author | Pete Cooper <peter_cooper@apple.com> | 2011-12-15 00:56:45 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2011-12-15 00:56:45 +0000 |
commit | b33c297f14a6cc40604f2fef4f80891780a37141 (patch) | |
tree | 2d3b95a8c9974862ea512336d6c36257b2a9c831 /llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | |
parent | e7f329fa7a35798b50e1c103716ff09bc2b2c9dc (diff) | |
download | bcm5719-llvm-b33c297f14a6cc40604f2fef4f80891780a37141.tar.gz bcm5719-llvm-b33c297f14a6cc40604f2fef4f80891780a37141.zip |
Added InstCombine for "select cond, ~cond, x" type patterns
These can be reduced to "~cond & x" or "~cond | x"
llvm-svn: 146624
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index 84f80f0d746..f1ea8ead1f9 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -682,6 +682,13 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { return BinaryOperator::CreateOr(CondVal, FalseVal); else if (CondVal == FalseVal) return BinaryOperator::CreateAnd(CondVal, TrueVal); + + // select a, ~a, b -> (~a)&b + // select a, b, ~a -> (~a)|b + if (match(TrueVal, m_Not(m_Specific(CondVal)))) + return BinaryOperator::CreateAnd(TrueVal, FalseVal); + else if (match(FalseVal, m_Not(m_Specific(CondVal)))) + return BinaryOperator::CreateOr(TrueVal, FalseVal); } // Selecting between two integer constants? |