Skip to content

Conversation

@shiltian
Copy link
Contributor

@shiltian shiltian commented Dec 7, 2025

Fixes SWDEV-570184.

Copy link
Contributor Author

shiltian commented Dec 7, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@shiltian shiltian requested a review from arsenm December 7, 2025 01:18
@llvmbot
Copy link
Member

llvmbot commented Dec 7, 2025

@llvm/pr-subscribers-backend-amdgpu

Author: Shilei Tian (shiltian)

Changes

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

2 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/SIISelLowering.cpp (+5)
  • (added) llvm/test/CodeGen/AMDGPU/inline-asm-use-bool.ll (+15)
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index ff67fd63ea75e..b5e6db178022c 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -17670,6 +17670,11 @@ SITargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI_,
       break;
     case 'v':
       switch (BitWidth) {
+      case 1:
+        RC = Subtarget->has1024AddressableVGPRs()
+                 ? &AMDGPU::VGPR_32_Lo256RegClass
+                 : &AMDGPU::VGPR_32RegClass;
+        break;
       case 16:
         RC = Subtarget->useRealTrue16Insts() ? &AMDGPU::VGPR_16RegClass
                                              : &AMDGPU::VGPR_32_Lo256RegClass;
diff --git a/llvm/test/CodeGen/AMDGPU/inline-asm-use-bool.ll b/llvm/test/CodeGen/AMDGPU/inline-asm-use-bool.ll
new file mode 100644
index 0000000000000..f26032656a2e9
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/inline-asm-use-bool.ll
@@ -0,0 +1,15 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx942 %s -o - | FileCheck %s
+; RUN: llc -global-isel=1 -mtriple=amdgcn-amd-amdhsa -mcpu=gfx942 %s -o - | FileCheck %s
+
+define void @test(ptr %p, i1 %b) {
+; CHECK-LABEL: test:
+; CHECK:       ; %bb.0:
+; CHECK-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; CHECK-NEXT:    ;;#ASMSTART
+; CHECK-NEXT:    global_store_byte v[0:1], v2, off glc slc
+; CHECK-NEXT:    ;;#ASMEND
+; CHECK-NEXT:    s_setpc_b64 s[30:31]
+  tail call void asm sideeffect "global_store_byte $0, $1, off glc slc", "v,v"(ptr %p, i1 %b)
+  ret void
+}

@shiltian shiltian force-pushed the users/shiltian/dont-use-vreg-1-for-inline-asm-bool branch 4 times, most recently from 4c6b751 to 6e34fec Compare December 8, 2025 15:00
define void @i1_used_as_vgpr_operand(ptr %p, i1 %b) {
tail call void asm sideeffect "global_store_byte $0, $1, off glc slc", "v,v"(ptr %p, i1 %b)
ret void
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Check the def case for good measure?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also AGPR + SGPR cases, those are probably equally broken

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check the def case for good measure?

What do you mean by "def case"?

Copy link
Contributor

Choose a reason for hiding this comment

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

call i1 asm "; def $0", "=v"()

@shiltian shiltian force-pushed the users/shiltian/dont-use-vreg-1-for-inline-asm-bool branch from 6e34fec to e65d0e7 Compare December 8, 2025 16:01
@shiltian shiltian merged commit 3ccd672 into main Dec 8, 2025
10 checks passed
@shiltian shiltian deleted the users/shiltian/dont-use-vreg-1-for-inline-asm-bool branch December 8, 2025 19:44
@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 9, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-mlir-rhel-clang running on ppc64le-mlir-rhel-test while building llvm at step 6 "test-build-check-mlir-build-only-check-mlir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/129/builds/34600

Here is the relevant piece of the build log for the reference
Step 6 (test-build-check-mlir-build-only-check-mlir) failure: 1200 seconds without output running [b'ninja', b'check-mlir'], attempting to kill
...
PASS: MLIR :: Pass/pipeline-options-parsing.mlir (3731 of 3742)
PASS: MLIR :: mlir-tblgen/op-interface.td (3732 of 3742)
PASS: MLIR-Unit :: Interfaces/./MLIRInterfacesTests/12/22 (3733 of 3742)
PASS: MLIR-Unit :: Interfaces/./MLIRInterfacesTests/13/22 (3734 of 3742)
PASS: MLIR-Unit :: Pass/./MLIRPassTests/10/13 (3735 of 3742)
PASS: MLIR :: mlir-tblgen/attr-or-type-format.td (3736 of 3742)
PASS: MLIR :: mlir-reduce/dce-test.mlir (3737 of 3742)
PASS: MLIR :: mlir-tblgen/llvm-intrinsics.td (3738 of 3742)
PASS: MLIR :: mlir-tblgen/op-error.td (3739 of 3742)
PASS: MLIR :: mlir-runner/simple.mlir (3740 of 3742)
command timed out: 1200 seconds without output running [b'ninja', b'check-mlir'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1739.659784

honeygoyal pushed a commit to honeygoyal/llvm-project that referenced this pull request Dec 9, 2025
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.

5 participants