From 75e8eb2b10b15b027608adb0d3eaaefbd19e5993 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Sat, 11 Sep 2021 10:52:00 -0400 Subject: [PATCH] [InstCombine] update code/test comments; NFC Follow-up for post-commit suggestion on: 28afaed691a0a7ca46bb9f64fac11 The comments were partly copied from the original code, but not updated to match the new code. --- .../lib/Transforms/InstCombine/InstCombineAddSub.cpp | 12 ++++++------ llvm/test/Transforms/InstCombine/sub-minmax.ll | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp index d96c0f88b46f..951b68b5d742 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -2057,11 +2057,11 @@ Instruction *InstCombinerImpl::visitSub(BinaryOperator &I) { return BinaryOperator::CreateAnd( Op0, Builder.CreateNot(Y, Y->getName() + ".not")); - // ~X - Min/Max(~X, O) -> Max/Min(X, ~O) - X - // ~X - Min/Max(O, ~X) -> Max/Min(X, ~O) - X - // Min/Max(~X, O) - ~X -> A - Max/Min(X, ~O) - // Min/Max(O, ~X) - ~X -> A - Max/Min(X, ~O) - // So long as O here is freely invertible, this will be neutral or a win. + // ~X - Min/Max(~X, Y) -> ~Min/Max(X, ~Y) - X + // ~X - Min/Max(Y, ~X) -> ~Min/Max(X, ~Y) - X + // Min/Max(~X, Y) - ~X -> X - ~Min/Max(X, ~Y) + // Min/Max(Y, ~X) - ~X -> X - ~Min/Max(X, ~Y) + // As long as Y is freely invertible, this will be neutral or a win. // Note: We don't generate the inverse max/min, just create the 'not' of // it and let other folds do the rest. if (match(Op0, m_Not(m_Value(X))) && @@ -2094,7 +2094,7 @@ Instruction *InstCombinerImpl::visitSub(BinaryOperator &I) { match(NotA, m_Not(m_Value(A))) && (NotA == LHS || NotA == RHS)) { if (NotA == LHS) std::swap(LHS, RHS); - // LHS is now O above and expected to have at least 2 uses (the min/max) + // LHS is now Y above and expected to have at least 2 uses (the min/max) // NotA is expected to have 2 uses from the min/max and 1 from the sub. if (isFreeToInvert(LHS, !LHS->hasNUsesOrMore(3)) && !NotA->hasNUsesOrMore(4)) { diff --git a/llvm/test/Transforms/InstCombine/sub-minmax.ll b/llvm/test/Transforms/InstCombine/sub-minmax.ll index a489c0f24ab8..5593b228592c 100644 --- a/llvm/test/Transforms/InstCombine/sub-minmax.ll +++ b/llvm/test/Transforms/InstCombine/sub-minmax.ll @@ -394,10 +394,10 @@ define void @umin3_not_all_ops_extra_uses_invert_subs(i8 %x, i8 %y, i8 %z) { } ; Handle this pattern with extra uses because it shows up in benchmarks. -; ~X - Min/Max(~X, O) -> Max/Min(X, ~O) - X -; ~X - Min/Max(O, ~X) -> Max/Min(X, ~O) - X -; Min/Max(~X, O) - ~X -> A - Max/Min(X, ~O) -; Min/Max(O, ~X) - ~X -> A - Max/Min(X, ~O) +; ~X - Min/Max(~X, Y) -> ~Min/Max(X, ~Y) - X +; ~X - Min/Max(Y, ~X) -> ~Min/Max(X, ~Y) - X +; Min/Max(~X, Y) - ~X -> X - ~Min/Max(X, ~Y) +; Min/Max(Y, ~X) - ~X -> X - ~Min/Max(X, ~Y) define i8 @umin_not_sub_intrinsic_commute0(i8 %x, i8 %y) { ; CHECK-LABEL: @umin_not_sub_intrinsic_commute0(