Skip to content

[RISCV] Use getCopyFromReg in unit test to match comment. NFC - #183199

Merged
topperc merged 1 commit into
llvm:mainfrom
topperc:pr/riscv-unittest
Feb 27, 2026
Merged

topperc merged 1 commit into
llvm:mainfrom
topperc:pr/riscv-unittest

Conversation

@topperc

@topperc topperc commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Using physical register 0, aka NoRegister, also just looked suspicious.

Using a physical register 0 also just look suspicious.
@llvmbot

llvmbot commented Feb 24, 2026

Copy link
Copy Markdown
Member

@llvm/pr-subscribers-backend-risc-v

Author: Craig Topper (topperc)

Changes

Using physical register 0, aka NoRegister, also just looked suspicious.


Full diff: https://github.com/llvm/llvm-project/pull/183199.diff

1 Files Affected:

  • (modified) llvm/unittests/Target/RISCV/RISCVSelectionDAGTest.cpp (+4-2)
diff --git a/llvm/unittests/Target/RISCV/RISCVSelectionDAGTest.cpp b/llvm/unittests/Target/RISCV/RISCVSelectionDAGTest.cpp
index 9c61aae358278..31c36fa5261ab 100644
--- a/llvm/unittests/Target/RISCV/RISCVSelectionDAGTest.cpp
+++ b/llvm/unittests/Target/RISCV/RISCVSelectionDAGTest.cpp
@@ -102,10 +102,12 @@ TEST_F(RISCVSelectionDAGTest, computeKnownBits_SRLW) {
   // The DAG created below is derived from this
   SDLoc Loc;
   auto Int64VT = EVT::getIntegerVT(Context, 64);
-  auto Px = DAG->getRegister(0, Int64VT);
+  auto Px = DAG->getCopyFromReg(DAG->getEntryNode(), Loc,
+                                Register::index2VirtReg(0), Int64VT);
   auto Py = DAG->getConstant(2147483647, Loc, Int64VT);
   auto N1 = DAG->getNode(ISD::AND, Loc, Int64VT, Px, Py);
-  auto Qx = DAG->getRegister(0, Int64VT);
+  auto Qx = DAG->getCopyFromReg(DAG->getEntryNode(), Loc,
+                                Register::index2VirtReg(1), Int64VT);
   auto N2 = DAG->getNode(RISCVISD::SRLW, Loc, Int64VT, N1, Qx);
   auto Py2 = DAG->getConstant(4294967295, Loc, Int64VT);
   auto N3 = DAG->getNode(ISD::AND, Loc, Int64VT, N2, Py2);

SDLoc Loc;
auto Int64VT = EVT::getIntegerVT(Context, 64);
auto Px = DAG->getRegister(0, Int64VT);
auto Px = DAG->getCopyFromReg(DAG->getEntryNode(), Loc,

@topperc topperc Feb 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentioned in the title is line 94 and line 96 above.

@RKSimon RKSimon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@topperc
topperc merged commit d2c5452 into llvm:main Feb 27, 2026
12 checks passed
@topperc
topperc deleted the pr/riscv-unittest branch February 27, 2026 18:00
sujianIBM pushed a commit to sujianIBM/llvm-project that referenced this pull request Mar 5, 2026
…83199)

Using physical register 0, aka NoRegister, also just looked suspicious.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants