Skip to content
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

[AMDGPU] Handle non-register operands for S_SUB/ADD_U64_PSEUDO #86104

Merged
merged 6 commits into from
Mar 25, 2024

Conversation

Pierre-vh
Copy link
Contributor

@Pierre-vh Pierre-vh commented Mar 21, 2024

This pseudo uses SSrc_b64 so it allows both an immediate or a register, but the lowering crashed on immediate operands.

This pseudo uses SSrc_b64 so it allows both an immediate or a register, but the lowering crashed
on register operands.
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 21, 2024

@llvm/pr-subscribers-backend-amdgpu

Author: Pierre van Houtryve (Pierre-vh)

Changes

This pseudo uses SSrc_b64 so it allows both an immediate or a register, but the lowering crashed on register operands.


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

1 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/SIISelLowering.cpp (+2-2)
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 5ccf21f76015de..045095684e845c 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -4858,8 +4858,8 @@ MachineBasicBlock *SITargetLowering::EmitInstrWithCustomInserter(
     if (Subtarget->hasScalarAddSub64()) {
       unsigned Opc = IsAdd ? AMDGPU::S_ADD_U64 : AMDGPU::S_SUB_U64;
       BuildMI(*BB, MI, DL, TII->get(Opc), Dest.getReg())
-          .addReg(Src0.getReg())
-          .addReg(Src1.getReg());
+          .add(Src0)
+          .add(Src1);
     } else {
       const SIRegisterInfo *TRI = ST.getRegisterInfo();
       const TargetRegisterClass *BoolRC = TRI->getBoolRC();

@arsenm
Copy link
Contributor

arsenm commented Mar 21, 2024

Missing test

Copy link

github-actions bot commented Mar 21, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 23de3862dce582ce91c1aa914467d982cb1a73b4 ef6356c5b6abf5a01014074e67e8dc52360aa957 -- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
View the diff from clang-format here.
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index e91136f66e..5a00d63b9b 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -4857,9 +4857,7 @@ MachineBasicBlock *SITargetLowering::EmitInstrWithCustomInserter(
     bool IsAdd = (MI.getOpcode() == AMDGPU::S_ADD_U64_PSEUDO);
     if (Subtarget->hasScalarAddSub64()) {
       unsigned Opc = IsAdd ? AMDGPU::S_ADD_U64 : AMDGPU::S_SUB_U64;
-      BuildMI(*BB, MI, DL, TII->get(Opc), Dest.getReg())
-        .add(Src0)
-        .add(Src1);
+      BuildMI(*BB, MI, DL, TII->get(Opc), Dest.getReg()).add(Src0).add(Src1);
     } else {
       const SIRegisterInfo *TRI = ST.getRegisterInfo();
       const TargetRegisterClass *BoolRC = TRI->getBoolRC();

@Pierre-vh
Copy link
Contributor Author

Missing test

How can I test ISel pseudo expansion? I didn't find the tests for it

@Pierre-vh
Copy link
Contributor Author

Missing test

How can I test ISel pseudo expansion? I didn't find the tests for it

This somewhat depends on #79553, we currently don't emit those pseudos so it can't be tested. Either that patch needs to add a test for it, or this whole patch should be merged with it

@Pierre-vh Pierre-vh requested a review from arsenm March 21, 2024 10:45
@jayfoad
Copy link
Contributor

jayfoad commented Mar 21, 2024

but the lowering crashed on register operands

Crashed on non-register operands?

@arsenm
Copy link
Contributor

arsenm commented Mar 21, 2024

Missing test

How can I test ISel pseudo expansion? I didn't find the tests for it

Ideally there would be a test that generated the failing pseudo in the first place, but you can also just run finalize-isel on MIR

@Pierre-vh
Copy link
Contributor Author

but the lowering crashed on register operands

Crashed on non-register operands?

Oops, I meant immediate

@Pierre-vh Pierre-vh requested a review from jayfoad March 22, 2024 10:34
Copy link
Contributor

@arsenm arsenm left a comment

Choose a reason for hiding this comment

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

A test that really selected this way would be better

llvm/test/CodeGen/AMDGPU/add_sub_u64_pseudos.mir Outdated Show resolved Hide resolved
@Pierre-vh Pierre-vh merged commit babbdad into llvm:main Mar 25, 2024
2 of 4 checks passed
@Pierre-vh Pierre-vh deleted the fix-sub64-pseudo-lower branch March 25, 2024 08:23
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.

None yet

4 participants