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 | 4e5a1ab10b62b7ca842afd0e99ac982153f217fb (patch) | |
tree | 6d1ec10d4f0722223378a44a48bf330829337f42 /lib/Transforms/InstCombine/InstCombineSelect.cpp | |
parent | 4e0adfa7f7fa5617a7a06028cdad0e4a50cac22a (diff) |
Added InstCombine for "select cond, ~cond, x" type patterns
These can be reduced to "~cond & x" or "~cond | x"
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146624 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineSelect.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineSelect.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineSelect.cpp b/lib/Transforms/InstCombine/InstCombineSelect.cpp index 84f80f0d74..f1ea8ead1f 100644 --- a/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/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? |