Skip to content

Conversation

rampitec
Copy link
Collaborator

This simply updates the pass's cognizance of these instructions, and for the
most part the hazards where they might be encountered do not exist for gfx12.
Nonetheless, encountering them has to be checked for as doing so would indicate
a compiler error.

Co-authored-by: Stephen Thomas [email protected]

@llvmbot
Copy link
Member

llvmbot commented Aug 15, 2025

@llvm/pr-subscribers-backend-amdgpu

Author: Stanislav Mekhanoshin (rampitec)

Changes

This simply updates the pass's cognizance of these instructions, and for the
most part the hazards where they might be encountered do not exist for gfx12.
Nonetheless, encountering them has to be checked for as doing so would indicate
a compiler error.

Co-authored-by: Stephen Thomas <[email protected]>


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

1 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp (+19)
diff --git a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
index c1cca063aac6f..fa3ca27a5f47c 100644
--- a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
@@ -1357,6 +1357,16 @@ bool GCNHazardRecognizer::fixSMEMtoVectorWriteHazards(MachineInstr *MI) {
         // DsCnt corresponds to LGKMCnt here.
         return (Decoded.DsCnt == 0);
       }
+      case AMDGPU::S_WAIT_STORECNT:
+      case AMDGPU::S_WAIT_STORECNT_DSCNT:
+      case AMDGPU::S_WAIT_LOADCNT:
+      case AMDGPU::S_WAIT_LOADCNT_DSCNT:
+      case AMDGPU::S_WAIT_SAMPLECNT:
+      case AMDGPU::S_WAIT_BVHCNT:
+      case AMDGPU::S_WAIT_DSCNT:
+      case AMDGPU::S_WAIT_EXPCNT:
+      case AMDGPU::S_WAIT_KMCNT:
+        llvm_unreachable("unexpected wait count instruction");
       default:
         // SOPP instructions cannot mitigate the hazard.
         if (TII->isSOPP(MI))
@@ -2254,6 +2264,15 @@ int GCNHazardRecognizer::checkFPAtomicToDenormModeHazard(MachineInstr *MI) {
     case AMDGPU::S_WAITCNT_EXPCNT:
     case AMDGPU::S_WAITCNT_LGKMCNT:
     case AMDGPU::S_WAIT_IDLE:
+    case AMDGPU::S_WAIT_LOADCNT:
+    case AMDGPU::S_WAIT_LOADCNT_DSCNT:
+    case AMDGPU::S_WAIT_SAMPLECNT:
+    case AMDGPU::S_WAIT_BVHCNT:
+    case AMDGPU::S_WAIT_STORECNT:
+    case AMDGPU::S_WAIT_STORECNT_DSCNT:
+    case AMDGPU::S_WAIT_EXPCNT:
+    case AMDGPU::S_WAIT_DSCNT:
+    case AMDGPU::S_WAIT_KMCNT:
       return true;
     default:
       break;

rampitec and others added 2 commits August 15, 2025 15:24
…t instructions

This simply updates the pass's cognizance of these instructions, and for the
most part the hazards where they might be encountered do not exist for gfx12.
Nonetheless, encountering them has to be checked for as doing so would indicate
a compiler error.

Co-authored-by: Stephen Thomas <[email protected]>
@rampitec rampitec force-pushed the users/rampitec/08-15-_amdgpu_update_gcnhazardrecognizer_s_understanding_of_gfx12_waitcount_instructions branch from 2f96c40 to df0ab0a Compare August 15, 2025 22:25
@rampitec rampitec force-pushed the users/rampitec/08-15-_amdgpu_w_a_for_s_setreg_b32_gfx1250_hazard_with_mode_register branch from 32fc495 to d9f7d86 Compare August 15, 2025 22:25
Base automatically changed from users/rampitec/08-15-_amdgpu_w_a_for_s_setreg_b32_gfx1250_hazard_with_mode_register to main August 15, 2025 23:08
…drecognizer_s_understanding_of_gfx12_waitcount_instructions
…drecognizer_s_understanding_of_gfx12_waitcount_instructions
@rampitec rampitec merged commit b7ec10c into main Aug 16, 2025
9 checks passed
@rampitec rampitec deleted the users/rampitec/08-15-_amdgpu_update_gcnhazardrecognizer_s_understanding_of_gfx12_waitcount_instructions branch August 16, 2025 00:18
case AMDGPU::S_WAIT_DSCNT:
case AMDGPU::S_WAIT_EXPCNT:
case AMDGPU::S_WAIT_KMCNT:
llvm_unreachable("unexpected wait count instruction");
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really like adding multiple lists of all the waitcnt instructions. #154087 tries to clean this up.

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.

4 participants