-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Support] Add KnownBits::computeForSubBorrow #65893 #67553
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
christiankissig
commented
Sep 27, 2023
- [Support] Add KnownBits::computeForSubBorrow
- [CodeGen] Implement USUBC, USUBO_CARRY, and SSUBO_CARRY with KnownBits::computeForSubBorrow
- [CodeGen] Compute unknown bits for Carry/Borrow for ADD/SUB
* Implements computeForSubBorrow as alias for computeforAddCarry. Borrow is expected to be 1-bit wide. * Adds exhaustive unit test.
…s::computeForSubBorrow
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.
You can test this locally with the following command:git-clang-format --diff 5109cb28fda8076f057c70bd25af7ed82de1d9b7 6355b54bafcec96770624a6a5df8e0c299be8f3f -- llvm/include/llvm/Support/KnownBits.h llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/lib/Support/KnownBits.cpp llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp llvm/unittests/Support/KnownBitsTest.cpp View the diff from clang-format here.diff --git a/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp b/llvm/unittests/CodeGen/AArch64SelectionDAGTest.cpp
index 0430c74f7..bb8e76a2e 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
|
Re-issuing PR after updating code formatting and rebasing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.