// RUN: %clang_cc1 -no-opaque-pointers %s -finclude-default-header -fdeclare-opencl-builtins -cl-std=clc++ -fblocks -O0 -emit-llvm -o - -triple "spir-unknown-unknown" | FileCheck %s
void testBranchingOnEnqueueKernel;
// CHECK: [[P:%[0-9]+]] = call spir_func i32 @__enqueue_kernel
// CHECK-NEXT: [[Q:%[a-z0-9]+]] = icmp ne i32 [[P]], 0
// CHECK-NEXT: br i1 [[Q]]
if
0;
// CHECK: [[P:%[0-9]+]] = call spir_func i32 @__get_kernel_work_group_size
// CHECK-NEXT: [[Q:%[a-z0-9]+]] = icmp ne i32 [[P]], 0
// CHECK-NEXT: br i1 [[Q]]
if
0;
// CHECK: [[P:%[0-9]+]] = call spir_func i32 @__get_kernel_preferred_work_group_size_multiple_impl
// CHECK-NEXT: [[Q:%[a-z0-9]+]] = icmp ne i32 [[P]], 0
// CHECK-NEXT: br i1 [[Q]]
}
void testBranchinOnPipeOperations {
// Verify that return type is correctly casted to i1 value.
if
0;
// CHECK: [[R:%[0-9]+]] = call spir_func i32 @__read_pipe_2
// CHECK-NEXT: icmp ne i32 [[R]], 0
if
0;
// CHECK: [[R:%[0-9]+]] = call spir_func i32 @__write_pipe_2
// CHECK-NEXT: icmp ne i32 [[R]], 0
if
0;
// CHECK: [[R:%[0-9]+]] = call spir_func i32 @__get_pipe_num_packets_ro
// CHECK-NEXT: icmp ne i32 [[R]], 0
if
0;
// CHECK: [[R:%[0-9]+]] = call spir_func i32 @__get_pipe_num_packets_wo
// CHECK-NEXT: icmp ne i32 [[R]], 0
if
0;
// CHECK: [[R:%[0-9]+]] = call spir_func i32 @__get_pipe_max_packets_ro
// CHECK-NEXT: icmp ne i32 [[R]], 0
if
0;
// CHECK: [[R:%[0-9]+]] = call spir_func i32 @__get_pipe_max_packets_wo
// CHECK-NEXT: icmp ne i32 [[R]], 0
}
void testBranchingOnAddressSpaceCast {
// Verify that pointer types are properly casted, respecting address spaces.
if
0;
// CHECK: [[P:%[0-9]+]] = call spir_func [[GLOBAL_VOID:i8 addrspace\ \*]] @__to_global
// CHECK-NEXT: [[Q:%[0-9]+]] = bitcast [[GLOBAL_VOID]] [[P]] to [[GLOBAL_i64:i64 addrspace\ \*]]
// CHECK-NEXT: [[BOOL:%[a-z0-9]+]] = icmp ne [[GLOBAL_i64]] [[Q]], null
// CHECK-NEXT: br i1 [[BOOL]]
if
0;
// CHECK: [[P:%[0-9]+]] = call spir_func [[LOCAL_VOID:i8 addrspace\ \*]] @__to_local
// CHECK-NEXT: [[Q:%[0-9]+]] = bitcast [[LOCAL_VOID]] [[P]] to [[LOCAL_i64:i64 addrspace\ \*]]
// CHECK-NEXT: [[BOOL:%[a-z0-9]+]] = icmp ne [[LOCAL_i64]] [[Q]], null
// CHECK-NEXT: br i1 [[BOOL]]
if
0;
// CHECK: [[P:%[0-9]+]] = call spir_func [[PRIVATE_VOID:i8\*]] @__to_private
// CHECK-NEXT: [[Q:%[0-9]+]] = bitcast [[PRIVATE_VOID]] [[P]] to [[PRIVATE_i64:i64\*]]
// CHECK-NEXT: [[BOOL:%[a-z0-9]+]] = icmp ne [[PRIVATE_i64]] [[Q]], null
// CHECK-NEXT: br i1 [[BOOL]]
}
{
// Ensure `enqueue_kernel` can be branched upon.
if
0