Skip to content

[M68k] incorrect assertion on move from CC register to data register #106210

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

Closed
TechnoElf opened this issue Aug 27, 2024 · 2 comments · Fixed by #114714
Closed

[M68k] incorrect assertion on move from CC register to data register #106210

TechnoElf opened this issue Aug 27, 2024 · 2 comments · Fixed by #114714
Labels
backend:m68k crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@TechnoElf
Copy link
Contributor

TechnoElf commented Aug 27, 2024

The assertion "Need DR8 register to copy CCR" in M68kInstrInfo::copyPhysReg appears to be wrong. According to the Programmer's Reference Manual, MOVE from CCR takes a 16bit destination operand and zero extends the 5 bits in the CC register.

@TechnoElf
Copy link
Contributor Author

Removing the assertion would be the obvious solution. At least the following change seems to compile code correctly:

--- a/llvm/lib/Target/M68k/M68kInstrInfo.cpp
+++ b/llvm/lib/Target/M68k/M68kInstrInfo.cpp
@@ -708,12 +708,12 @@ void M68kInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
   bool ToSR = DstReg == M68k::SR;

   if (FromCCR) {
-    assert(M68k::DR8RegClass.contains(DstReg) &&
-           "Need DR8 register to copy CCR");
+    //assert(M68k::DR8RegClass.contains(DstReg) &&
+    //       "Need DR8 register to copy CCR");
     Opc = M68k::MOV8dc;
   } else if (ToCCR) {
-    assert(M68k::DR8RegClass.contains(SrcReg) &&
-           "Need DR8 register to copy CCR");
+    //assert(M68k::DR8RegClass.contains(SrcReg) &&
+    //       "Need DR8 register to copy CCR");
     Opc = M68k::MOV8cd;
   } else if (FromSR || ToSR)
     llvm_unreachable("Cannot emit SR copy instruction");

@EugeneZelenko EugeneZelenko added backend:m68k crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Aug 27, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 27, 2024

@llvm/issue-subscribers-backend-m68k

Author: Janis Heims (TechnoElf)

The assertion "Need DR8 register to copy CCR" in M68kInstrInfo::copyPhysReg appears to be wrong. According to the Programmer's Reference Manual, MOVE from CCR takes a 16bit destination operand and zero extends the 5 bits in the CC register.

mshockwave pushed a commit that referenced this issue Nov 27, 2024
Builds on @TechnoElf 's CCR MOV pr
#107591 and adds some tests.

Fixes #106210.

---------

Co-authored-by: TechnoElf <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:m68k crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
3 participants