summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorranapratap55 <RanaPratapReddy.Nimmakayala@amd.com>2025-11-21 00:06:54 +0530
committerranapratap55 <RanaPratapReddy.Nimmakayala@amd.com>2025-11-21 07:03:55 +0530
commitcff4602d4a69a96712a335203e5748de5b40b295 (patch)
treec3c0141e6f3acd20b7d288a27acac5932bf27df3
parent1c42262dc348664be14724734ea1639632507425 (diff)
[AMDGPU] Treating HIP/C++ _Float16 same as OpenCL's halfusers/ranapratap55/extended-image-fp16-openCL-fix
-rw-r--r--clang/lib/AST/ASTContext.cpp15
-rw-r--r--clang/test/SemaOpenCL/builtins-extended-image-param-gfx1100-err.cl2
-rw-r--r--clang/test/SemaOpenCL/builtins-extended-image-param-gfx942-err.cl2
3 files changed, 17 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index fab907b9c1a4..82422f2eac6b 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -10527,6 +10527,21 @@ bool ASTContext::areCompatibleVectorTypes(QualType FirstVec,
Second->getVectorKind() != VectorKind::RVVFixedLengthMask_4)
return true;
+ // In OpenCL, treat half and _Float16 vector types as compatible.
+ if (getLangOpts().OpenCL &&
+ First->getNumElements() == Second->getNumElements()) {
+ QualType FirstElt = First->getElementType();
+ QualType SecondElt = Second->getElementType();
+
+ if ((FirstElt->isFloat16Type() && SecondElt->isHalfType()) ||
+ (FirstElt->isHalfType() && SecondElt->isFloat16Type())) {
+ if (First->getVectorKind() != VectorKind::AltiVecPixel &&
+ First->getVectorKind() != VectorKind::AltiVecBool &&
+ Second->getVectorKind() != VectorKind::AltiVecPixel &&
+ Second->getVectorKind() != VectorKind::AltiVecBool)
+ return true;
+ }
+ }
return false;
}
diff --git a/clang/test/SemaOpenCL/builtins-extended-image-param-gfx1100-err.cl b/clang/test/SemaOpenCL/builtins-extended-image-param-gfx1100-err.cl
index 4ed65e6e32f9..47dbdd4e5178 100644
--- a/clang/test/SemaOpenCL/builtins-extended-image-param-gfx1100-err.cl
+++ b/clang/test/SemaOpenCL/builtins-extended-image-param-gfx1100-err.cl
@@ -5,7 +5,7 @@
typedef int int4 __attribute__((ext_vector_type(4)));
typedef float float4 __attribute__((ext_vector_type(4)));
-typedef _Float16 half4 __attribute__((ext_vector_type(4)));
+typedef half half4 __attribute__((ext_vector_type(4)));
float4 test_amdgcn_image_gather4_lz_2d_v4f32_f32_r(float4 v4f32, float f32, int i32, __amdgpu_texture_t tex, int4 vec4i32) {
diff --git a/clang/test/SemaOpenCL/builtins-extended-image-param-gfx942-err.cl b/clang/test/SemaOpenCL/builtins-extended-image-param-gfx942-err.cl
index 95818b0aea38..e60f8c70dc7c 100644
--- a/clang/test/SemaOpenCL/builtins-extended-image-param-gfx942-err.cl
+++ b/clang/test/SemaOpenCL/builtins-extended-image-param-gfx942-err.cl
@@ -5,7 +5,7 @@
typedef int int4 __attribute__((ext_vector_type(4)));
typedef float float4 __attribute__((ext_vector_type(4)));
-typedef _Float16 half4 __attribute__((ext_vector_type(4)));
+typedef half half4 __attribute__((ext_vector_type(4)));
float4 test_amdgcn_image_gather4_lz_2d_v4f32_f32_r(float4 v4f32, float f32, int i32, __amdgpu_texture_t tex, int4 vec4i32) {