summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2018-09-10 23:47:21 +0000
committerAlina Sbirlea <asbirlea@google.com>2018-09-10 23:47:21 +0000
commit116caa2920c5fc2758ca18a37e7fa0e630b7aa7e (patch)
tree0c504decf11a973600277f93a0fc323eafec5b0e /llvm/lib
parentcd7bd8262a53a8162f8829587ff509e23f684952 (diff)
downloadbcm5719-llvm-116caa2920c5fc2758ca18a37e7fa0e630b7aa7e.tar.gz
bcm5719-llvm-116caa2920c5fc2758ca18a37e7fa0e630b7aa7e.zip
[InstCombine] Partially revert rL341674 due to PR38897.
Summary: Revert min/max changes in rL341674 dues to high compile times causing timeouts (PR38897). Checking in to unblock failing builds. Patch available for post-commit review and re-revert once resolved. Working on a smaller reproducer for PR38897. Reviewers: craig.topper, spatel Subscribers: sanjoy, jlebar, llvm-commits Differential Revision: https://reviews.llvm.org/D51897 llvm-svn: 341883
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp43
1 files changed, 8 insertions, 35 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index e710c486706..622b6eace5d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -1827,42 +1827,15 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
}
// MAX(~a, ~b) -> ~MIN(a, b)
- // MAX(~a, C) -> ~MIN(a, ~C)
// MIN(~a, ~b) -> ~MAX(a, b)
- // MIN(~a, C) -> ~MAX(a, ~C)
- auto moveNotAfterMinMax = [&](Value *X, Value *Y,
- bool Swapped) -> Instruction * {
- Value *A;
- if (match(X, m_Not(m_Value(A))) && !X->hasNUsesOrMore(3) &&
- // Passing false to only consider m_Not and constants.
- IsFreeToInvert(Y, false)) {
- Value *B = Builder.CreateNot(Y);
- Value *NewMinMax = createMinMax(Builder, getInverseMinMaxFlavor(SPF),
- A, B);
- // Copy the profile metadata.
- if (MDNode *MD = SI.getMetadata(LLVMContext::MD_prof)) {
- cast<SelectInst>(NewMinMax)->setMetadata(LLVMContext::MD_prof, MD);
- // Swap the metadata if the operands are swapped.
- if (Swapped) {
- assert(X == SI.getFalseValue() && Y == SI.getTrueValue() &&
- "Unexpected operands.");
- cast<SelectInst>(NewMinMax)->swapProfMetadata();
- } else {
- assert(X == SI.getTrueValue() && Y == SI.getFalseValue() &&
- "Unexpected operands.");
- }
- }
-
- return BinaryOperator::CreateNot(NewMinMax);
- }
-
- return nullptr;
- };
-
- if (Instruction *I = moveNotAfterMinMax(LHS, RHS, /*Swapped*/false))
- return I;
- if (Instruction *I = moveNotAfterMinMax(RHS, LHS, /*Swapped*/true))
- return I;
+ Value *A, *B;
+ if (match(LHS, m_Not(m_Value(A))) && match(RHS, m_Not(m_Value(B))) &&
+ (!LHS->hasNUsesOrMore(3) || !RHS->hasNUsesOrMore(3))) {
+ CmpInst::Predicate InvertedPred = getInverseMinMaxPred(SPF);
+ Value *InvertedCmp = Builder.CreateICmp(InvertedPred, A, B);
+ Value *NewSel = Builder.CreateSelect(InvertedCmp, A, B);
+ return BinaryOperator::CreateNot(NewSel);
+ }
if (Instruction *I = factorizeMinMaxTree(SPF, LHS, RHS, Builder))
return I;
OpenPOWER on IntegriCloud