[AMDGPU] More precise limit on SALU cycles in s_delay_alu instructions
authorJay Foad <jay.foad@amd.com>
Sun, 5 Mar 2023 08:12:02 +0000 (08:12 +0000)
committerJay Foad <jay.foad@amd.com>
Sun, 5 Mar 2023 08:14:15 +0000 (08:14 +0000)
This just tweaks the fix for D145232 to make the limit more precise, so
that we could actually emit a delay of 3 SALU cycles (the maximum) if we
had any SALU instructions that required it.

llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp

index 57d0fda..a3a1306 100644 (file)
@@ -83,9 +83,9 @@ public:
     // an s_delay_alu instruction.
     static constexpr unsigned TRANS_MAX = 4;
 
-    // The maximum number of SALU cycles we can encode in an s_delay_alu
-    // instruction.
-    static constexpr unsigned SALU_CYCLES_MAX = 3;
+    // One larger than the maximum number of SALU cycles we can encode in an
+    // s_delay_alu instruction.
+    static constexpr unsigned SALU_CYCLES_MAX = 4;
 
     // If it was written by a (non-TRANS) VALU, remember how many clock cycles
     // are left until it completes, and how many other (non-TRANS) VALU we have
@@ -284,6 +284,7 @@ public:
 
     // Wait for an SALU instruction.
     if (Delay.SALUCycles) {
+      assert(Delay.SALUCycles < DelayInfo::SALU_CYCLES_MAX);
       if (Imm & 0x780) {
         // We have already encoded a VALU and a TRANS delay. There's no room in
         // the encoding for an SALU delay as well, so just drop it.