[llvm] [NVPTX] Update architecture support checks for tcgen05 intrinsics (PR #161519)

Durgadoss R via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 7 01:36:34 PDT 2025


================
@@ -72,6 +72,40 @@ const SelectionDAGTargetInfo *NVPTXSubtarget::getSelectionDAGInfo() const {
   return TSInfo.get();
 }
 
+bool NVPTXSubtarget::hasPTXWithFamilySMs(unsigned PTXVersion,
+                                         ArrayRef<unsigned> SMVersions) const {
+  unsigned PTXVer = getPTXVersion();
+  if (!hasFamilySpecificFeatures() || PTXVer < PTXVersion)
+    return false;
+
+  unsigned SMVer = getSmVersion();
+  return llvm::any_of(SMVersions, [&](unsigned SM) {
+    // sm_101 is a different family, never group it with sm_10x.
+    if (SMVer == 101 || SM == 101)
+      return SMVer == SM &&
+             // PTX 9.0 and later renamed sm_101 to sm_110, so sm_101 is not
+             // supported.
+             !(PTXVer >= 90 && SMVer == 101);
+
+    return getSmFamilyVersion() == SM / 10 && SMVer >= SM;
+  });
+}
+
+bool NVPTXSubtarget::hasPTXWithAccelSMs(unsigned PTXVersion,
+                                        ArrayRef<unsigned> SMVersions) const {
+  unsigned PTXVer = getPTXVersion();
+  if (!hasArchAccelFeatures() || PTXVer < PTXVersion)
+    return false;
+
+  unsigned SMVer = getSmVersion();
+  return llvm::any_of(SMVersions, [&](unsigned SM) {
+    return SMVer == SM &&
+           // PTX 9.0 and later renamed sm_101 to sm_110, so sm_101 is not
+           // supported.
+           !(PTXVer >= 90 && SMVer == 101);
----------------
durga4github wrote:

Since the PTXVersion check is anyway separate, I wonder if we can simplify this by hoisting the deprecated version check outside the lambda. (after line 100)

```
unsigned SMVer = getSmVersion();
// PTX 9.0 and later renamed sm_101 to sm_110, so sm_101 is not supported
if (SMVer == 101 && PTXVer >= 90)
    return false;

return llvm::any_of(SMVersions, [&](unsigned SM) { return SMVer == SM });
```

With this, I think, we can simply do an llvm::find:
return llvm::find(SMVersions, SMVer) != SMVersions.end();


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


More information about the llvm-commits mailing list