Skip to content

[X86][AMX] Fix a bug after #83628 #91207

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

Merged
merged 2 commits into from
May 15, 2024
Merged

[X86][AMX] Fix a bug after #83628 #91207

merged 2 commits into from
May 15, 2024

Conversation

phoebewang
Copy link
Contributor

We need to check if GR64Cand a valid register before using it.

Test is not needed since it's covered in llvm-test-suite.

Fixes #90954

We need to check if `GR64Cand` a valid register before using it.

Test is not needed since it's covered in llvm-test-suite.

Fixes llvm#90954
@phoebewang phoebewang requested review from fhahn and RKSimon May 6, 2024 13:48
@llvmbot
Copy link
Member

llvmbot commented May 6, 2024

@llvm/pr-subscribers-backend-x86

Author: Phoebe Wang (phoebewang)

Changes

We need to check if GR64Cand a valid register before using it.

Test is not needed since it's covered in llvm-test-suite.

Fixes #90954


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

1 Files Affected:

  • (modified) llvm/lib/Target/X86/X86LowerTileCopy.cpp (+2-2)
diff --git a/llvm/lib/Target/X86/X86LowerTileCopy.cpp b/llvm/lib/Target/X86/X86LowerTileCopy.cpp
index fd05e16ac1ceff..60c024556ff13f 100644
--- a/llvm/lib/Target/X86/X86LowerTileCopy.cpp
+++ b/llvm/lib/Target/X86/X86LowerTileCopy.cpp
@@ -146,7 +146,7 @@ bool X86LowerTileCopy::runOnMachineFunction(MachineFunction &MF) {
           addFrameReference(BuildMI(MBB, MI, DL, TII->get(Opc)), TileSS)
               .addReg(SrcReg, getKillRegState(SrcMO.isKill()));
       MachineOperand &MO = NewMI->getOperand(2);
-      MO.setReg(GR64Cand);
+      MO.setReg(GR64Cand ? GR64Cand : X86::RAX);
       MO.setIsKill(true);
       // tileloadd (%sp, %idx), %tmm
       Opc = GET_EGPR_IF_ENABLED(X86::TILELOADD);
@@ -157,7 +157,7 @@ bool X86LowerTileCopy::runOnMachineFunction(MachineFunction &MF) {
         // restore %rax
         // mov (%sp) %rax
         addFrameReference(
-            BuildMI(MBB, MI, DL, TII->get(X86::MOV64rm), GR64Cand), StrideSS);
+            BuildMI(MBB, MI, DL, TII->get(X86::MOV64rm), X86::RAX), StrideSS);
       }
       MI.eraseFromParent();
       Changed = true;

@phoebewang
Copy link
Contributor Author

Ping?

Copy link
Collaborator

@RKSimon RKSimon left a comment

Choose a reason for hiding this comment

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

LGTM as a fix, would be nice to get a crash test added though if you can.

@phoebewang
Copy link
Contributor Author

LGTM as a fix, would be nice to get a crash test added though if you can.

Done. The LLVM bugpoint cannot work for AMX tests, finally reduced it with the help of #92280.

@phoebewang phoebewang merged commit b576a6b into llvm:main May 15, 2024
3 of 4 checks passed
@phoebewang phoebewang deleted the AMX branch May 15, 2024 15:15
phoebewang added a commit to phoebewang/llvm-project that referenced this pull request May 16, 2024
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.

[X86] Crash when building SingleSource/UnitTests/Matrix/AMXINT8/t_gemm_bf16.cpp: Assertion `RegNo && RegNo < 388 && "Invalid register number!"'
3 participants