diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-01-06 17:34:22 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-01-06 17:34:22 +0000 |
| commit | 26a6fcde83f94543405373dcff0ae86afb24cea9 (patch) | |
| tree | 7da0c994dc46424f01249512f3fb04191acf3de7 /llvm/lib/Transforms | |
| parent | f7e775291e0c41125f889206b0328627524e5c65 (diff) | |
| download | bcm5719-llvm-26a6fcde83f94543405373dcff0ae86afb24cea9.tar.gz bcm5719-llvm-26a6fcde83f94543405373dcff0ae86afb24cea9.zip | |
[InstCombine] relax use constraint for min/max (~a, ~b) --> ~min/max(a, b)
In the minimal case, this won't remove instructions, but it still improves
uses of existing values.
In the motivating example from PR35834, it does remove instructions, and
sets that case up to be optimized by something like D41603:
https://reviews.llvm.org/D41603
llvm-svn: 321936
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index b02865c1290..96b8b4ffac6 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -1555,8 +1555,8 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { // MAX(~a, ~b) -> ~MIN(a, b) // MIN(~a, ~b) -> ~MAX(a, b) Value *A, *B; - if (match(LHS, m_Not(m_Value(A))) && LHS->getNumUses() <= 2 && - match(RHS, m_Not(m_Value(B))) && RHS->getNumUses() <= 2) { + if (match(LHS, m_Not(m_Value(A))) && match(RHS, m_Not(m_Value(B))) && + (LHS->getNumUses() <= 2 || RHS->getNumUses() <= 2)) { CmpInst::Predicate InvertedPred = getCmpPredicateForMinMax(getInverseMinMaxSelectPattern(SPF)); Value *InvertedCmp = Builder.CreateICmp(InvertedPred, A, B); |

