Skip to content

[RISCV][NFC] Remove VRRegMO of tryAddHint #85755

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

Conversation

wangpc-pp
Copy link
Contributor

It is only used in assertion.

Created using spr 1.3.4
@wangpc-pp wangpc-pp requested a review from topperc March 19, 2024 08:55
@wangpc-pp wangpc-pp requested a review from preames March 19, 2024 08:55
@llvmbot
Copy link
Member

llvmbot commented Mar 19, 2024

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

Author: Wang Pengcheng (wangpc-pp)

Changes

It is only used in assertion.


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

1 Files Affected:

  • (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp (+6-7)
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
index a68674b221d38e..fa970b07016f1e 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
@@ -738,12 +738,11 @@ bool RISCVRegisterInfo::getRegAllocationHints(
   // Add any two address hints after any copy hints.
   SmallSet<Register, 4> TwoAddrHints;
 
-  auto tryAddHint = [&](const MachineOperand &VRRegMO, const MachineOperand &MO,
-                        bool NeedGPRC) -> void {
+  auto tryAddHint = [&](const MachineOperand &MO, bool NeedGPRC) -> void {
     Register Reg = MO.getReg();
     Register PhysReg = Reg.isPhysical() ? Reg : Register(VRM->getPhys(Reg));
     if (PhysReg && (!NeedGPRC || RISCV::GPRCRegClass.contains(PhysReg))) {
-      assert(!MO.getSubReg() && !VRRegMO.getSubReg() && "Unexpected subreg!");
+      assert(!MO.getSubReg() && "Unexpected subreg!");
       if (!MRI->isReserved(PhysReg) && !is_contained(Hints, PhysReg))
         TwoAddrHints.insert(PhysReg);
     }
@@ -826,16 +825,16 @@ bool RISCVRegisterInfo::getRegAllocationHints(
         if (!NeedGPRC || MI.getNumExplicitOperands() < 3 ||
             MI.getOpcode() == RISCV::ADD_UW ||
             isCompressibleOpnd(MI.getOperand(2)))
-          tryAddHint(MO, MI.getOperand(1), NeedGPRC);
+          tryAddHint(MI.getOperand(1), NeedGPRC);
         if (MI.isCommutable() && MI.getOperand(2).isReg() &&
             (!NeedGPRC || isCompressibleOpnd(MI.getOperand(1))))
-          tryAddHint(MO, MI.getOperand(2), NeedGPRC);
+          tryAddHint(MI.getOperand(2), NeedGPRC);
       } else if (OpIdx == 1 && (!NeedGPRC || MI.getNumExplicitOperands() < 3 ||
                                 isCompressibleOpnd(MI.getOperand(2)))) {
-        tryAddHint(MO, MI.getOperand(0), NeedGPRC);
+        tryAddHint(MI.getOperand(0), NeedGPRC);
       } else if (MI.isCommutable() && OpIdx == 2 &&
                  (!NeedGPRC || isCompressibleOpnd(MI.getOperand(1)))) {
-        tryAddHint(MO, MI.getOperand(0), NeedGPRC);
+        tryAddHint(MI.getOperand(0), NeedGPRC);
       }
     }
   }

@topperc
Copy link
Collaborator

topperc commented Mar 19, 2024

Why is it ok to remove the assertion?

@wangpc-pp
Copy link
Contributor Author

Why is it ok to remove the assertion?

IIUC, there will be no subregs for those opcodes and operands?
I just think it may not be a good practice to pass an argument for assertion.

@topperc
Copy link
Collaborator

topperc commented Mar 20, 2024

With #85982 I am able to hit these assertions with Zdinx on RV32.

@wangpc-pp wangpc-pp closed this Mar 21, 2024
@wangpc-pp wangpc-pp deleted the users/wangpc-pp/spr/riscvnfc-remove-vrregmo-of-tryaddhint branch March 21, 2024 05:37
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