[Lldb-commits] [lldb] [Support] Add KnownBits::computeForSubBorrow (PR #67788)

Christian Kissig via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 5 07:54:53 PDT 2023


https://github.com/christiankissig updated https://github.com/llvm/llvm-project/pull/67788

>From 5d86936c3a48c613460983c980271fcab8128b75 Mon Sep 17 00:00:00 2001
From: Christian Kissig <dev at kissig.fastmail.fm>
Date: Tue, 26 Sep 2023 12:18:59 +0000
Subject: [PATCH 1/5] [Support] Add KnownBits::computeForSubBorrow

* Implements computeForSubBorrow as alias for computeforAddCarry. Borrow
  is expected to be 1-bit wide.
* Adds exhaustive unit test.
---
 llvm/include/llvm/Support/KnownBits.h    |  4 +++
 llvm/lib/Support/KnownBits.cpp           | 12 +++++++++
 llvm/unittests/Support/KnownBitsTest.cpp | 31 ++++++++++++++++++++++++
 3 files changed, 47 insertions(+)

diff --git a/llvm/include/llvm/Support/KnownBits.h b/llvm/include/llvm/Support/KnownBits.h
index 8462aa11202d5d7..711ca8c12129a1b 100644
--- a/llvm/include/llvm/Support/KnownBits.h
+++ b/llvm/include/llvm/Support/KnownBits.h
@@ -332,6 +332,10 @@ struct KnownBits {
   static KnownBits computeForAddSub(bool Add, bool NSW, const KnownBits &LHS,
                                     KnownBits RHS);
 
+  /// Compute known bits results from subtracting RHS from LHS.
+  static KnownBits computeForSubBorrow(const KnownBits &LHS, KnownBits RHS,
+                                       const KnownBits &Borrow);
+
   /// Compute knownbits resulting from llvm.sadd.sat(LHS, RHS)
   static KnownBits sadd_sat(const KnownBits &LHS, const KnownBits &RHS);
 
diff --git a/llvm/lib/Support/KnownBits.cpp b/llvm/lib/Support/KnownBits.cpp
index 097c22d33dd12ba..99ac50a34666fce 100644
--- a/llvm/lib/Support/KnownBits.cpp
+++ b/llvm/lib/Support/KnownBits.cpp
@@ -85,6 +85,18 @@ KnownBits KnownBits::computeForAddSub(bool Add, bool NSW,
   return KnownOut;
 }
 
+KnownBits KnownBits::computeForSubBorrow(const KnownBits &LHS, KnownBits RHS,
+                                         const KnownBits &Borrow) {
+  assert(Borrow.getBitWidth() == 1 && "Borrow must be 1-bit");
+
+  // LHS - RHS = LHS + ~RHS + 1
+  // Carry 1 - Borrow in ::computeForAddCarry
+  std::swap(RHS.Zero, RHS.One);
+  return ::computeForAddCarry(LHS, RHS,
+                              /*CarryZero*/ Borrow.One.getBoolValue(),
+                              /*CarryOne*/ Borrow.Zero.getBoolValue());
+}
+
 KnownBits KnownBits::sextInReg(unsigned SrcBitWidth) const {
   unsigned BitWidth = getBitWidth();
   assert(0 < SrcBitWidth && SrcBitWidth <= BitWidth &&
diff --git a/llvm/unittests/Support/KnownBitsTest.cpp b/llvm/unittests/Support/KnownBitsTest.cpp
index 9d184beea3ba9e9..5597d69ab248d23 100644
--- a/llvm/unittests/Support/KnownBitsTest.cpp
+++ b/llvm/unittests/Support/KnownBitsTest.cpp
@@ -213,6 +213,37 @@ TEST(KnownBitsTest, AddSubExhaustive) {
   TestAddSubExhaustive(false);
 }
 
+TEST(KnownBitsTest, SubBorrowExhaustive) {
+  unsigned Bits = 4;
+  ForeachKnownBits(Bits, [&](const KnownBits &Known1) {
+    ForeachKnownBits(Bits, [&](const KnownBits &Known2) {
+      ForeachKnownBits(1, [&](const KnownBits &KnownBorrow) {
+        // Explicitly compute known bits of the addition by trying all
+        // possibilities.
+        KnownBits Known(Bits);
+        Known.Zero.setAllBits();
+        Known.One.setAllBits();
+        ForeachNumInKnownBits(Known1, [&](const APInt &N1) {
+          ForeachNumInKnownBits(Known2, [&](const APInt &N2) {
+            ForeachNumInKnownBits(KnownBorrow, [&](const APInt &Borrow) {
+              APInt Sub = N1 - N2;
+              if (Borrow.getBoolValue())
+                --Sub;
+
+              Known.One &= Sub;
+              Known.Zero &= ~Sub;
+            });
+          });
+        });
+
+        KnownBits KnownComputed =
+            KnownBits::computeForSubBorrow(Known1, Known2, KnownBorrow);
+        EXPECT_EQ(Known, KnownComputed);
+      });
+    });
+  });
+}
+
 TEST(KnownBitsTest, BinaryExhaustive) {
   testBinaryOpExhaustive(
       [](const KnownBits &Known1, const KnownBits &Known2) {

>From f84c882cf429df238054d88ee07e41a08ae3fd6c Mon Sep 17 00:00:00 2001
From: Christian Kissig <dev at kissig.fastmail.fm>
Date: Tue, 26 Sep 2023 18:02:49 +0000
Subject: [PATCH 2/5] [CodeGen] Implement USUBC, USUBO_CARRY, and SSUBO_CARRY
 with KnownBits::computeForSubBorrow

---
 .../lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 12 ++++++----
 .../CodeGen/AArch64SelectionDAGTest.cpp       | 24 +++++++++++++++++++
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index cd21af770e1a4d9..ab3e9b4bdc67402 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -3732,14 +3732,18 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
     assert(Op.getResNo() == 0 &&
            "We only compute knownbits for the difference here.");
 
-    // TODO: Compute influence of the carry operand.
+    // With UADDO_CARRY and SSUBO_CARRY a borrow bit may be added in.
+    KnownBits Borrow(1);
     if (Opcode == ISD::USUBO_CARRY || Opcode == ISD::SSUBO_CARRY)
-      break;
+      // TODO: Compute known bits for the carry operand. Creates
+      // parity with UADDO_CARRY And SADDO_CARRY as of now.
+      Borrow.resetAll();
+    else
+      Borrow.setAllZero();
 
     Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
     Known2 = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1);
-    Known = KnownBits::computeForAddSub(/* Add */ false, /* NSW */ false,
-                                        Known, Known2);
+    Known = KnownBits::computeForSubBorrow(Known, Known2, Borrow);
     break;
   }
   case ISD::UADDO:
diff --git a/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp b/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp
index 0e1f2736907fff8..303ee50a763fba3 100644
--- a/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp
+++ b/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp
@@ -273,6 +273,30 @@ TEST_F(AArch64SelectionDAGTest, ComputeKnownBits_SUB) {
   EXPECT_EQ(Known.One, APInt(8, 0x1));
 }
 
+// Piggy-backing on the AArch64 tests to verify SelectionDAG::computeKnownBits.
+TEST_F(AArch64SelectionDAGTest, ComputeKnownBits_USUBO_CARRY) {
+  SDLoc Loc;
+  auto IntVT = EVT::getIntegerVT(Context, 8);
+  auto N0 = DAG->getConstant(0x5a, Loc, IntVT);
+  auto UnknownOp1 = DAG->getRegister(0, IntVT);        // ????????
+  auto Mask1_Zero = DAG->getConstant(0x8, Loc, IntVT); // 00001000
+  auto Mask1_One = DAG->getConstant(0x20, Loc, IntVT); // 00100000
+  // N1 = (???????? & 00001000) | 00100000 = 0010?000
+  auto N1 = DAG->getNode(ISD::AND, Loc, IntVT, Mask1_Zero, UnknownOp1);
+  N1 = DAG->getNode(ISD::OR, Loc, IntVT, Mask1_One, N1);
+  auto UnknownOpC = DAG->getRegister(1, IntVT);
+  auto Op = DAG->getNode(ISD::USUBO_CARRY, Loc, IntVT, N0, N1, UnknownOpC);
+  // N0 = 01011010
+  // N1 = 0010?000
+  // C  =        ?
+  //  =>
+  // Known.Zero = 11000100 (0xc4)
+  // Known.One  = 00110000 (0x30)
+  KnownBits Known = DAG->computeKnownBits(Op);
+  EXPECT_EQ(Known.Zero, APInt(8, 0xc4));
+  EXPECT_EQ(Known.One, APInt(8, 0x30));
+}
+
 TEST_F(AArch64SelectionDAGTest, isSplatValue_Fixed_BUILD_VECTOR) {
   TargetLowering TL(*TM);
 

>From 6355b54bafcec96770624a6a5df8e0c299be8f3f Mon Sep 17 00:00:00 2001
From: Christian Kissig <dev at kissig.fastmail.fm>
Date: Wed, 27 Sep 2023 12:35:59 +0000
Subject: [PATCH 3/5] [CodeGen] Compute unknown bits for Carry/Borrow for
 ADD/SUB

Computes known bits for carry/borrow for UADDO_CARRY and USUBO_CARRY
Operations. Carry/borrow are expected to be 1-bit. 0 bits are padded
with unknown.

Adds a unit test for UADDO_CARRY and USUBO_CARRY.
---
 .../lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 23 ++---
 .../CodeGen/AArch64SelectionDAGTest.cpp       | 95 +++++++++++++++++--
 2 files changed, 99 insertions(+), 19 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index ab3e9b4bdc67402..5c01baa9dedff4e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -3734,11 +3734,11 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
 
     // With UADDO_CARRY and SSUBO_CARRY a borrow bit may be added in.
     KnownBits Borrow(1);
-    if (Opcode == ISD::USUBO_CARRY || Opcode == ISD::SSUBO_CARRY)
-      // TODO: Compute known bits for the carry operand. Creates
-      // parity with UADDO_CARRY And SADDO_CARRY as of now.
-      Borrow.resetAll();
-    else
+    if (Opcode == ISD::USUBO_CARRY || Opcode == ISD::SSUBO_CARRY) {
+      Borrow = computeKnownBits(Op.getOperand(2), DemandedElts, Depth + 1);
+      // Borrow has bit width 1
+      Borrow = Borrow.zextOrTrunc(1);
+    } else
       Borrow.setAllZero();
 
     Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
@@ -3768,14 +3768,11 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
     if (Opcode == ISD::ADDE)
       // Can't track carry from glue, set carry to unknown.
       Carry.resetAll();
-    else if (Opcode == ISD::UADDO_CARRY || Opcode == ISD::SADDO_CARRY)
-      // TODO: Compute known bits for the carry operand. Not sure if it is worth
-      // the trouble (how often will we find a known carry bit). And I haven't
-      // tested this very much yet, but something like this might work:
-      //   Carry = computeKnownBits(Op.getOperand(2), DemandedElts, Depth + 1);
-      //   Carry = Carry.zextOrTrunc(1, false);
-      Carry.resetAll();
-    else
+    else if (Opcode == ISD::UADDO_CARRY || Opcode == ISD::SADDO_CARRY) {
+      Carry = computeKnownBits(Op.getOperand(2), DemandedElts, Depth + 1);
+      // Carry has bit width 1
+      Carry = Carry.zextOrTrunc(1);
+    } else
       Carry.setAllZero();
 
     Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
diff --git a/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp b/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp
index 303ee50a763fba3..0430c74f7d17ca8 100644
--- a/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp
+++ b/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp
@@ -254,6 +254,59 @@ TEST_F(AArch64SelectionDAGTest, ComputeKnownBits_ADD) {
   EXPECT_EQ(Known.One, APInt(8, 0x55));
 }
 
+// Piggy-backing on the AArch64 tests to verify SelectionDAG::computeKnownBits.
+TEST_F(AArch64SelectionDAGTest, ComputeKnownBits_UADDO_CARRY) {
+  SDLoc Loc;
+  auto IntVT = EVT::getIntegerVT(Context, 8);
+  auto UnknownOp = DAG->getRegister(0, IntVT);
+  auto Mask_Zero = DAG->getConstant(0x28, Loc, IntVT);
+  auto Mask_One = DAG->getConstant(0x20, Loc, IntVT);
+  auto N0 = DAG->getNode(ISD::AND, Loc, IntVT, Mask_Zero, UnknownOp);
+  N0 = DAG->getNode(ISD::OR, Loc, IntVT, Mask_One, N0);
+  auto N1 = DAG->getConstant(0x65, Loc, IntVT);
+
+  KnownBits Known;
+
+  auto UnknownBorrow = DAG->getRegister(1, IntVT);
+  auto OpUnknownBorrow = DAG->getNode(
+      ISD::UADDO_CARRY, Loc, IntVT, N0, N1, UnknownBorrow);
+  // N0 = 0010?000
+  // N1 = 01100101
+  // B  =        ?
+  //  =>
+  // Known.Zero = 01110000 (0x70)
+  // Known.One  = 10000100 (0x84)
+  Known = DAG->computeKnownBits(OpUnknownBorrow);
+  EXPECT_EQ(Known.Zero, APInt(8, 0x70));
+  EXPECT_EQ(Known.One, APInt(8, 0x84));
+
+  auto ZeroBorrow = DAG->getConstant(0x0, Loc, IntVT);
+  auto OpZeroBorrow = DAG->getNode(
+      ISD::UADDO_CARRY, Loc, IntVT, N0, N1, ZeroBorrow);
+  // N0 = 0010?000
+  // N1 = 01100101
+  // B  =        0
+  //  =>
+  // Known.Zero = 01110010 (0x72)
+  // Known.One  = 10000101 (0x85)
+  Known = DAG->computeKnownBits(OpZeroBorrow);
+  EXPECT_EQ(Known.Zero, APInt(8, 0x72));
+  EXPECT_EQ(Known.One, APInt(8, 0x85));
+
+  auto OneBorrow = DAG->getConstant(0x1, Loc, IntVT);
+  auto OpOneBorrow = DAG->getNode(
+      ISD::UADDO_CARRY, Loc, IntVT, N0, N1, OneBorrow);
+  // N0 = 0010?000
+  // N1 = 01100101
+  // B  =        1
+  //  =>
+  // Known.Zero = 01110001 (0x71)
+  // Known.One  = 10000110 (0x86)
+  Known = DAG->computeKnownBits(OpOneBorrow);
+  EXPECT_EQ(Known.Zero, APInt(8, 0x71));
+  EXPECT_EQ(Known.One, APInt(8, 0x86)); 
+}
+
 // Piggy-backing on the AArch64 tests to verify SelectionDAG::computeKnownBits.
 TEST_F(AArch64SelectionDAGTest, ComputeKnownBits_SUB) {
   SDLoc Loc;
@@ -278,23 +331,53 @@ TEST_F(AArch64SelectionDAGTest, ComputeKnownBits_USUBO_CARRY) {
   SDLoc Loc;
   auto IntVT = EVT::getIntegerVT(Context, 8);
   auto N0 = DAG->getConstant(0x5a, Loc, IntVT);
-  auto UnknownOp1 = DAG->getRegister(0, IntVT);        // ????????
+  auto UnknownOp = DAG->getRegister(0, IntVT);        // ????????
   auto Mask1_Zero = DAG->getConstant(0x8, Loc, IntVT); // 00001000
   auto Mask1_One = DAG->getConstant(0x20, Loc, IntVT); // 00100000
   // N1 = (???????? & 00001000) | 00100000 = 0010?000
-  auto N1 = DAG->getNode(ISD::AND, Loc, IntVT, Mask1_Zero, UnknownOp1);
+  auto N1 = DAG->getNode(ISD::AND, Loc, IntVT, Mask1_Zero, UnknownOp);
   N1 = DAG->getNode(ISD::OR, Loc, IntVT, Mask1_One, N1);
-  auto UnknownOpC = DAG->getRegister(1, IntVT);
-  auto Op = DAG->getNode(ISD::USUBO_CARRY, Loc, IntVT, N0, N1, UnknownOpC);
+
+  KnownBits Known;
+
+  auto UnknownBorrow = DAG->getRegister(1, IntVT);
+  auto OpUnknownBorrow = DAG->getNode(
+      ISD::USUBO_CARRY, Loc, IntVT, N0, N1, UnknownBorrow);
   // N0 = 01011010
   // N1 = 0010?000
-  // C  =        ?
+  // B  =        ?
   //  =>
   // Known.Zero = 11000100 (0xc4)
   // Known.One  = 00110000 (0x30)
-  KnownBits Known = DAG->computeKnownBits(Op);
+  Known = DAG->computeKnownBits(OpUnknownBorrow);
   EXPECT_EQ(Known.Zero, APInt(8, 0xc4));
   EXPECT_EQ(Known.One, APInt(8, 0x30));
+
+  auto ZeroBorrow = DAG->getConstant(0x0, Loc, IntVT);
+  auto OpZeroBorrow = DAG->getNode(
+      ISD::USUBO_CARRY, Loc, IntVT, N0, N1, ZeroBorrow);
+  // N0 = 01011010
+  // N1 = 0010?000
+  // B  =        0
+  //  =>
+  // Known.Zero = 11000101 (0xc5)
+  // Known.One  = 00110010 (0x32)
+  Known = DAG->computeKnownBits(OpZeroBorrow);
+  EXPECT_EQ(Known.Zero, APInt(8, 0xc5));
+  EXPECT_EQ(Known.One, APInt(8, 0x32));
+
+  auto OneBorrow = DAG->getConstant(0x1, Loc, IntVT);
+  auto OpOneBorrow = DAG->getNode(
+      ISD::USUBO_CARRY, Loc, IntVT, N0, N1, OneBorrow);
+  // N0 = 01011010
+  // N1 = 0010?000
+  // B  =        1
+  //  =>
+  // Known.Zero = 11000110 (0xc6)
+  // Known.One  = 00110001 (0x31)
+  Known = DAG->computeKnownBits(OpOneBorrow);
+  EXPECT_EQ(Known.Zero, APInt(8, 0xc6));
+  EXPECT_EQ(Known.One, APInt(8, 0x31));
 }
 
 TEST_F(AArch64SelectionDAGTest, isSplatValue_Fixed_BUILD_VECTOR) {

>From 108d899c04aa80e2d65fc34b49e40ae82594cf10 Mon Sep 17 00:00:00 2001
From: Christian Kissig <dev at kissig.fastmail.fm>
Date: Thu, 28 Sep 2023 11:50:25 +0000
Subject: [PATCH 4/5] [CodeGen] Compute known bits of Carry/Borrow for UADDO,
 SADDO, USUBO, and SSUBO

Adds computeKnownBits for Carry/Borrow for UADDO, SADDO, USUBO, and SSUBO.
Carry over is expected to be of bit width 1. Adds unit tests for UADDO_CARRY
and USUBO_CARRY.
---
 .../CodeGen/AArch64SelectionDAGTest.cpp       | 28 +++++++++----------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp b/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp
index 0430c74f7d17ca8..bb8e76a2eeb8beb 100644
--- a/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp
+++ b/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp
@@ -268,8 +268,8 @@ TEST_F(AArch64SelectionDAGTest, ComputeKnownBits_UADDO_CARRY) {
   KnownBits Known;
 
   auto UnknownBorrow = DAG->getRegister(1, IntVT);
-  auto OpUnknownBorrow = DAG->getNode(
-      ISD::UADDO_CARRY, Loc, IntVT, N0, N1, UnknownBorrow);
+  auto OpUnknownBorrow =
+      DAG->getNode(ISD::UADDO_CARRY, Loc, IntVT, N0, N1, UnknownBorrow);
   // N0 = 0010?000
   // N1 = 01100101
   // B  =        ?
@@ -281,8 +281,8 @@ TEST_F(AArch64SelectionDAGTest, ComputeKnownBits_UADDO_CARRY) {
   EXPECT_EQ(Known.One, APInt(8, 0x84));
 
   auto ZeroBorrow = DAG->getConstant(0x0, Loc, IntVT);
-  auto OpZeroBorrow = DAG->getNode(
-      ISD::UADDO_CARRY, Loc, IntVT, N0, N1, ZeroBorrow);
+  auto OpZeroBorrow =
+      DAG->getNode(ISD::UADDO_CARRY, Loc, IntVT, N0, N1, ZeroBorrow);
   // N0 = 0010?000
   // N1 = 01100101
   // B  =        0
@@ -294,8 +294,8 @@ TEST_F(AArch64SelectionDAGTest, ComputeKnownBits_UADDO_CARRY) {
   EXPECT_EQ(Known.One, APInt(8, 0x85));
 
   auto OneBorrow = DAG->getConstant(0x1, Loc, IntVT);
-  auto OpOneBorrow = DAG->getNode(
-      ISD::UADDO_CARRY, Loc, IntVT, N0, N1, OneBorrow);
+  auto OpOneBorrow =
+      DAG->getNode(ISD::UADDO_CARRY, Loc, IntVT, N0, N1, OneBorrow);
   // N0 = 0010?000
   // N1 = 01100101
   // B  =        1
@@ -304,7 +304,7 @@ TEST_F(AArch64SelectionDAGTest, ComputeKnownBits_UADDO_CARRY) {
   // Known.One  = 10000110 (0x86)
   Known = DAG->computeKnownBits(OpOneBorrow);
   EXPECT_EQ(Known.Zero, APInt(8, 0x71));
-  EXPECT_EQ(Known.One, APInt(8, 0x86)); 
+  EXPECT_EQ(Known.One, APInt(8, 0x86));
 }
 
 // Piggy-backing on the AArch64 tests to verify SelectionDAG::computeKnownBits.
@@ -331,7 +331,7 @@ TEST_F(AArch64SelectionDAGTest, ComputeKnownBits_USUBO_CARRY) {
   SDLoc Loc;
   auto IntVT = EVT::getIntegerVT(Context, 8);
   auto N0 = DAG->getConstant(0x5a, Loc, IntVT);
-  auto UnknownOp = DAG->getRegister(0, IntVT);        // ????????
+  auto UnknownOp = DAG->getRegister(0, IntVT);         // ????????
   auto Mask1_Zero = DAG->getConstant(0x8, Loc, IntVT); // 00001000
   auto Mask1_One = DAG->getConstant(0x20, Loc, IntVT); // 00100000
   // N1 = (???????? & 00001000) | 00100000 = 0010?000
@@ -341,8 +341,8 @@ TEST_F(AArch64SelectionDAGTest, ComputeKnownBits_USUBO_CARRY) {
   KnownBits Known;
 
   auto UnknownBorrow = DAG->getRegister(1, IntVT);
-  auto OpUnknownBorrow = DAG->getNode(
-      ISD::USUBO_CARRY, Loc, IntVT, N0, N1, UnknownBorrow);
+  auto OpUnknownBorrow =
+      DAG->getNode(ISD::USUBO_CARRY, Loc, IntVT, N0, N1, UnknownBorrow);
   // N0 = 01011010
   // N1 = 0010?000
   // B  =        ?
@@ -354,8 +354,8 @@ TEST_F(AArch64SelectionDAGTest, ComputeKnownBits_USUBO_CARRY) {
   EXPECT_EQ(Known.One, APInt(8, 0x30));
 
   auto ZeroBorrow = DAG->getConstant(0x0, Loc, IntVT);
-  auto OpZeroBorrow = DAG->getNode(
-      ISD::USUBO_CARRY, Loc, IntVT, N0, N1, ZeroBorrow);
+  auto OpZeroBorrow =
+      DAG->getNode(ISD::USUBO_CARRY, Loc, IntVT, N0, N1, ZeroBorrow);
   // N0 = 01011010
   // N1 = 0010?000
   // B  =        0
@@ -367,8 +367,8 @@ TEST_F(AArch64SelectionDAGTest, ComputeKnownBits_USUBO_CARRY) {
   EXPECT_EQ(Known.One, APInt(8, 0x32));
 
   auto OneBorrow = DAG->getConstant(0x1, Loc, IntVT);
-  auto OpOneBorrow = DAG->getNode(
-      ISD::USUBO_CARRY, Loc, IntVT, N0, N1, OneBorrow);
+  auto OpOneBorrow =
+      DAG->getNode(ISD::USUBO_CARRY, Loc, IntVT, N0, N1, OneBorrow);
   // N0 = 01011010
   // N1 = 0010?000
   // B  =        1

>From 3e91c2b0798659e48643fe3806200fb18afc812a Mon Sep 17 00:00:00 2001
From: Christian Kissig <dev at kissig.fastmail.fm>
Date: Fri, 29 Sep 2023 13:01:14 +0000
Subject: [PATCH 5/5] [CodeGen] Fix typo

---
 llvm/unittests/Support/KnownBitsTest.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/unittests/Support/KnownBitsTest.cpp b/llvm/unittests/Support/KnownBitsTest.cpp
index 5597d69ab248d23..c0377d45c303a11 100644
--- a/llvm/unittests/Support/KnownBitsTest.cpp
+++ b/llvm/unittests/Support/KnownBitsTest.cpp
@@ -218,7 +218,7 @@ TEST(KnownBitsTest, SubBorrowExhaustive) {
   ForeachKnownBits(Bits, [&](const KnownBits &Known1) {
     ForeachKnownBits(Bits, [&](const KnownBits &Known2) {
       ForeachKnownBits(1, [&](const KnownBits &KnownBorrow) {
-        // Explicitly compute known bits of the addition by trying all
+        // Explicitly compute known bits of the subtraction by trying all
         // possibilities.
         KnownBits Known(Bits);
         Known.Zero.setAllBits();



More information about the lldb-commits mailing list