https://github.com/arsenm created 
https://github.com/llvm/llvm-project/pull/188472

Report cl_khr_subgroup_extended_types for AMDGPU when targeting
the llvm environment.

>From a31ac425e6e14062924a70ca97c5e5e68234060e Mon Sep 17 00:00:00 2001
From: Matt Arsenault <[email protected]>
Date: Wed, 25 Mar 2026 13:01:22 +0100
Subject: [PATCH] clang: Report subgroup ext types for AMDGPU with llvm env

Report cl_khr_subgroup_extended_types for AMDGPU when targeting
the llvm environment.
---
 clang/lib/Basic/Targets/AMDGPU.h             |  4 ++++
 clang/test/Misc/amdgcn.languageOptsOpenCL.cl | 14 ++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 08ccc668f78b6..38030ba07f9be 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -346,6 +346,10 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
         Opts["__opencl_c_device_enqueue"] = true;
         Opts["__opencl_c_pipes"] = true;
       }
+
+      if (getTriple().getEnvironment() == llvm::Triple::LLVM) {
+        Opts["cl_khr_subgroup_extended_types"] = true;
+      }
     }
   }
 
diff --git a/clang/test/Misc/amdgcn.languageOptsOpenCL.cl 
b/clang/test/Misc/amdgcn.languageOptsOpenCL.cl
index fd42912854020..5e611329b518d 100644
--- a/clang/test/Misc/amdgcn.languageOptsOpenCL.cl
+++ b/clang/test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -14,6 +14,8 @@
 // Test none target with amdhsa triple, which implies >= gfx700
 // RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple 
amdgcn-unknown-amdhsa -Wpedantic-core-features -DTEST_CORE_FEATURES 
-DFLAT_SUPPORT
 
+// RUN: %clang_cc1 -x cl -cl-std=CL3.0 %s -verify -triple 
amdgcn-unknown-amdhsa-llvm -Wpedantic-core-features -DTEST_CORE_FEATURES 
-DFLAT_SUPPORT -DLLVM_ENV_EXTENSIONS
+
 // Extensions in all versions
 #ifndef cl_clang_storage_class_specifiers
 #error "Missing cl_clang_storage_class_specifiers define"
@@ -219,3 +221,15 @@
     #endif
   #endif
 #endif
+
+#ifdef LLVM_ENV_EXTENSIONS
+  // Features available with llvm env
+  #ifndef cl_khr_subgroup_extended_types
+    #error "missing cl_khr_subgroup_extended_types define"
+  #endif
+#else
+  // Features not available with unknown environment.
+  #ifdef cl_khr_subgroup_extended_types
+    #error "incorrect cl_khr_subgroup_extended_types define"
+  #endif
+#endif

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to