[clang] [llvm] [llvm][AMDGPU] Fold `llvm.amdgcn.wavefrontsize` early (PR #114481)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 24 14:11:40 PST 2024


================
@@ -1024,6 +1024,15 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
     }
     break;
   }
+  case Intrinsic::amdgcn_wavefrontsize: {
+    // TODO: this is a workaround for the pseudo-generic target one gets with no
+    // specified mcpu, which spoofs its wave size to 64; it should be removed.
+    if ((ST->getCPU().empty() || ST->getCPU().starts_with("generic")) &&
+        !ST->getFeatureString().contains("+wavefrontsize"))
+      break;
+    return IC.replaceInstUsesWith(
+        II, ConstantInt::get(II.getType(), ST->getWavefrontSize()));
+  }
----------------
jhuber6 wrote:

I suppose this is now this?
```
if (ST->isWaveSizeKnown())
 return IC.replaceInstUsesWith(
        II, ConstantInt::get(II.getType(), ST->getWavefrontSize()));
```

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


More information about the cfe-commits mailing list