[llvm] [AMDGPU] Handle unset/max flat workgroup size in waves/EU (PR #139955)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Wed May 14 14:23:13 PDT 2025


================
@@ -1170,13 +1170,19 @@ struct AAAMDWavesPerEU : public AAAMDSizeRangeAttribute {
           !AssumedGroupSize->isValidState())
         return false;
 
+      unsigned MinFWGSize =
+          AssumedGroupSize->getAssumed().getLower().getZExtValue();
+      unsigned MaxFWGSize =
+          AssumedGroupSize->getAssumed().getUpper().getZExtValue();
+      if (MinFWGSize == 0 && MaxFWGSize == 0)
+        std::tie(MinFWGSize, MaxFWGSize) =
+            InfoCache.getDefaultFlatWorkGroupSize(*Func);
----------------
shiltian wrote:

If both of them are zero, it means the flat workgroup size AA still doesn't reach fixed point since its state is still valid.

> Isn't it always safe (correctness-wise) to use max that function allows ?

Yes, it is always safe to use max, but then there is no point to have this waves per eu AA. Using the default/max value here basically pushes waves per eu to its worst state, and it can't be optimized later on, even if a more optimal flat work group size is encountered. That is because the growth of flat workgroup size and waves per eu is in different direction, and the value gets from waves per eu always dominates the values propagated here.

To fix this properly, we should not use flat workgroup size here at all, which is exactly what https://github.com/llvm/llvm-project/pull/123995 is doing. The intermediate value of work group size should not be used to define waves per eu.

https://github.com/llvm/llvm-project/pull/139955


More information about the llvm-commits mailing list