| 1 |
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 |
| 2 |
// RUN: %clang_cc1 -triple spirv64-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -x hip -emit-llvm -fcuda-is-device -o - %s | FileCheck %s |
| 3 |
|
| 4 |
// Unlike OpenCL, HIP depends on the C++ interpration of "unsigned long", which |
| 5 |
// is 64 bits long on Linux and 32 bits long on Windows. The return type of the |
| 6 |
// ballot intrinsic needs to be a 64 bit integer on both platforms. This test |
| 7 |
// cross-compiles to Windows to confirm that the return type is indeed 64 bits |
| 8 |
// on Windows. |
| 9 |
|
| 10 |
#define __device__ __attribute__((device)) |
| 11 |
|
| 12 |
// CHECK-LABEL: define spir_func noundef i64 @_Z3fooi( |
| 13 |
// CHECK-SAME: i32 noundef [[P:%.*]]) addrspace(4) #[[ATTR0:[0-9]+]] { |
| 14 |
// CHECK-NEXT: entry: |
| 15 |
// CHECK-NEXT: [[RETVAL:%.*]] = alloca i64, align 8 |
| 16 |
// CHECK-NEXT: [[P_ADDR:%.*]] = alloca i32, align 4 |
| 17 |
// CHECK-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr [[RETVAL]] to ptr addrspace(4) |
| 18 |
// CHECK-NEXT: [[P_ADDR_ASCAST:%.*]] = addrspacecast ptr [[P_ADDR]] to ptr addrspace(4) |
| 19 |
// CHECK-NEXT: store i32 [[P]], ptr addrspace(4) [[P_ADDR_ASCAST]], align 4 |
| 20 |
// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr addrspace(4) [[P_ADDR_ASCAST]], align 4 |
| 21 |
// CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[TMP0]], 0 |
| 22 |
// CHECK-NEXT: [[TMP1:%.*]] = call addrspace(4) i64 @llvm.amdgcn.ballot.i64(i1 [[TOBOOL]]) |
| 23 |
// CHECK-NEXT: ret i64 [[TMP1]] |
| 24 |
// |
| 25 |
__device__ unsigned long long foo(int p) { |
| 26 |
return __builtin_amdgcn_ballot_w64(p); |
| 27 |
} |