xref: /llvm-project/clang/test/CodeGenCUDA/redux-builtins.cu (revision 0419465fa4358af1ec808e376e3881377bfac76b)
1 // RUN: %clang_cc1 "-triple" "nvptx-nvidia-cuda" "-target-feature" "+ptx70" "-target-cpu" "sm_80" -emit-llvm -fcuda-is-device -o - %s | FileCheck %s
2 // RUN: %clang_cc1 "-triple" "nvptx64-nvidia-cuda" "-target-feature" "+ptx70" "-target-cpu" "sm_80" -emit-llvm -fcuda-is-device -o - %s | FileCheck %s
3 
4 // CHECK: define{{.*}} void @_Z6kernelPi(ptr noundef %out)
kernel(int * out)5 __attribute__((global)) void kernel(int *out) {
6   int a = 1;
7   unsigned int b = 5;
8   int i = 0;
9 
10   out[i++] = __nvvm_redux_sync_add(a, 0xFF);
11   // CHECK: call i32 @llvm.nvvm.redux.sync.add
12 
13   out[i++] = __nvvm_redux_sync_add(b, 0x01);
14   // CHECK: call i32 @llvm.nvvm.redux.sync.add
15 
16   out[i++] = __nvvm_redux_sync_min(a, 0x0F);
17   // CHECK: call i32 @llvm.nvvm.redux.sync.min
18 
19   out[i++] = __nvvm_redux_sync_umin(b, 0xF0);
20   // CHECK: call i32 @llvm.nvvm.redux.sync.umin
21 
22   out[i++] = __nvvm_redux_sync_max(a, 0xF0);
23   // CHECK: call i32 @llvm.nvvm.redux.sync.max
24 
25   out[i++] = __nvvm_redux_sync_umax(b, 0x0F);
26   // CHECK: call i32 @llvm.nvvm.redux.sync.umax
27 
28   out[i++] = __nvvm_redux_sync_and(a, 0xF0);
29   // CHECK: call i32 @llvm.nvvm.redux.sync.and
30 
31   out[i++] = __nvvm_redux_sync_and(b, 0x0F);
32   // CHECK: call i32 @llvm.nvvm.redux.sync.and
33 
34   out[i++] = __nvvm_redux_sync_xor(a, 0x10);
35   // CHECK: call i32 @llvm.nvvm.redux.sync.xor
36 
37   out[i++] = __nvvm_redux_sync_xor(b, 0x01);
38   // CHECK: call i32 @llvm.nvvm.redux.sync.xor
39 
40   out[i++] = __nvvm_redux_sync_or(a, 0xFF);
41   // CHECK: call i32 @llvm.nvvm.redux.sync.or
42 
43   out[i++] = __nvvm_redux_sync_or(b, 0xFF);
44   // CHECK: call i32 @llvm.nvvm.redux.sync.or
45 
46   // CHECK: ret void
47 }
48