[InstCombine] update code/test comments; NFC
authorSanjay Patel <spatel@rotateright.com>
Sat, 11 Sep 2021 14:52:00 +0000 (10:52 -0400)
committerSanjay Patel <spatel@rotateright.com>
Sat, 11 Sep 2021 14:53:53 +0000 (10:53 -0400)
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.

llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/test/Transforms/InstCombine/sub-minmax.ll

index d96c0f8..951b68b 100644 (file)
@@ -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)) {
index a489c0f..5593b22 100644 (file)
@@ -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(