[llvm] ee62dcd - [InstCombine] Remove SPF moveNotAfterMinMax() (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 28 01:26:21 PST 2022
Author: Nikita Popov
Date: 2022-02-28T10:23:07+01:00
New Revision: ee62dcdb3461d3f9d1e246fe4f30ef5feb0e6bc6
URL: https://github.com/llvm/llvm-project/commit/ee62dcdb3461d3f9d1e246fe4f30ef5feb0e6bc6
DIFF: https://github.com/llvm/llvm-project/commit/ee62dcdb3461d3f9d1e246fe4f30ef5feb0e6bc6.diff
LOG: [InstCombine] Remove SPF moveNotAfterMinMax() (NFC)
This happens after SPF -> intrinsic canonicalization, and as such
should be entirely NFC.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 47bc45c10134..8c9c5053e891 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -2988,8 +2988,6 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
if (Instruction *R = foldSPFofSPF(cast<Instruction>(RHS), SPF2, LHS2,
RHS2, SI, SPF, LHS))
return R;
- // TODO.
- // ABS(-X) -> ABS(X)
}
if (SelectPatternResult::isMinOrMax(SPF)) {
@@ -3025,38 +3023,6 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
return replaceInstUsesWith(SI, NewCast);
}
- // 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) -> Instruction * {
- Value *A;
- if (match(X, m_Not(m_Value(A))) && !X->hasNUsesOrMore(3) &&
- !isFreeToInvert(A, A->hasOneUse()) &&
- // 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 (X == SI.getFalseValue() && Y == SI.getTrueValue())
- cast<SelectInst>(NewMinMax)->swapProfMetadata();
- }
-
- return BinaryOperator::CreateNot(NewMinMax);
- }
-
- return nullptr;
- };
-
- if (Instruction *I = moveNotAfterMinMax(LHS, RHS))
- return I;
- if (Instruction *I = moveNotAfterMinMax(RHS, LHS))
- return I;
-
if (Instruction *I = moveAddAfterMinMax(SPF, LHS, RHS, Builder))
return I;
More information about the llvm-commits
mailing list