77// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -triple spirv64-unknown-unknown -o %t.ll
88// RUN: FileCheck %s --input-file=%t.ll --check-prefix=OG-LLVM
99
10- typedef __attribute__ (( ext_vector_type (3 ) )) char char3 ;
1110typedef __attribute__ (( ext_vector_type (4 ) )) char char4 ;
12- typedef __attribute__ (( ext_vector_type (16 ) )) char char16 ;
13- typedef __attribute__ (( ext_vector_type (3 ) )) int int3 ;
1411
15- //CIR: cir.func @f4(%{{.*}}: !s32i loc({{.*}})) -> !cir.vector<!s8i x 4>
16- //CIR: %[[x:.*]] = cir.load align(4) %{{.*}} : !cir.ptr<!s32i, addrspace(offload_private)>
17- //CIR: cir.cast bitcast %[[x]] : !s32i -> !cir.vector<!s8i x 4>
18- //LLVM: define spir_func <4 x i8> @f4(i32 %[[x:.*]])
19- //LLVM: %[[astype:.*]] = bitcast i32 %[[x]] to <4 x i8>
20- //LLVM-NOT: shufflevector
21- //LLVM: ret <4 x i8> %[[astype]]
22- //OG-LLVM: define spir_func noundef <4 x i8> @f4(i32 noundef %[[x:.*]])
23- //OG-LLVM: %[[astype:.*]] = bitcast i32 %[[x]] to <4 x i8>
24- //OG-LLVM-NOT: shufflevector
25- //OG-LLVM: ret <4 x i8> %[[astype]]
12+ // CIR: cir.func @f4(%{{.*}}: !s32i loc({{.*}})) -> !cir.vector<!s8i x 4>
13+ // CIR: %[[x:.*]] = cir.load align(4) %{{.*}} : !cir.ptr<!s32i, addrspace(offload_private)>
14+ // CIR: cir.cast bitcast %[[x]] : !s32i -> !cir.vector<!s8i x 4>
15+ // LLVM: define spir_func <4 x i8> @f4(i32 %[[x:.*]])
16+ // LLVM: %[[astype:.*]] = bitcast i32 %[[x]] to <4 x i8>
17+ // LLVM-NOT: shufflevector
18+ // LLVM: ret <4 x i8> %[[astype]]
19+ // OG-LLVM: define spir_func noundef <4 x i8> @f4(i32 noundef %[[x:.*]])
20+ // OG-LLVM: %[[astype:.*]] = bitcast i32 %[[x]] to <4 x i8>
21+ // OG-LLVM-NOT: shufflevector
22+ // OG-LLVM: ret <4 x i8> %[[astype]]
2623char4 f4 (int x ) {
2724 return __builtin_astype (x , char4 );
2825}
2926
30- //CIR: cir.func @f6(%{{.*}}: !cir.vector<!s8i x 4> loc({{.*}})) -> !s32i
31- //CIR: %[[x:.*]] = cir.load align(4) %{{.*}} : !cir.ptr<!cir.vector<!s8i x 4>, addrspace(offload_private)>, !cir.vector<!s8i x 4>
32- //CIR: cir.cast bitcast %[[x]] : !cir.vector<!s8i x 4> -> !s32i
33- //LLVM: define{{.*}} spir_func i32 @f6(<4 x i8> %[[x:.*]])
34- //LLVM: %[[astype:.*]] = bitcast <4 x i8> %[[x]] to i32
35- //LLVM-NOT: shufflevector
36- //LLVM: ret i32 %[[astype]]
37- //OG-LLVM: define{{.*}} spir_func noundef i32 @f6(<4 x i8> noundef %[[x:.*]])
38- //OG-LLVM: %[[astype:.*]] = bitcast <4 x i8> %[[x]] to i32
39- //OG-LLVM-NOT: shufflevector
40- //OG-LLVM: ret i32 %[[astype]]
27+ // CIR: cir.func @f6(%{{.*}}: !cir.vector<!s8i x 4> loc({{.*}})) -> !s32i
28+ // CIR: %[[x:.*]] = cir.load align(4) %{{.*}} : !cir.ptr<!cir.vector<!s8i x 4>, addrspace(offload_private)>, !cir.vector<!s8i x 4>
29+ // CIR: cir.cast bitcast %[[x]] : !cir.vector<!s8i x 4> -> !s32i
30+ // LLVM: define{{.*}} spir_func i32 @f6(<4 x i8> %[[x:.*]])
31+ // LLVM: %[[astype:.*]] = bitcast <4 x i8> %[[x]] to i32
32+ // LLVM-NOT: shufflevector
33+ // LLVM: ret i32 %[[astype]]
34+ // OG-LLVM: define{{.*}} spir_func noundef i32 @f6(<4 x i8> noundef %[[x:.*]])
35+ // OG-LLVM: %[[astype:.*]] = bitcast <4 x i8> %[[x]] to i32
36+ // OG-LLVM-NOT: shufflevector
37+ // OG-LLVM: ret i32 %[[astype]]
4138int f6 (char4 x ) {
4239 return __builtin_astype (x , int );
40+ }
41+
42+ // CIR: cir.func @f4_ptr(%{{.*}}: !cir.ptr<!s32i, addrspace(offload_global)> loc({{.*}})) -> !cir.ptr<!cir.vector<!s8i x 4>, addrspace(offload_local)>
43+ // CIR: %[[x:.*]] = cir.load align(8) %{{.*}} : !cir.ptr<!cir.ptr<!s32i, addrspace(offload_global)>, addrspace(offload_private)>, !cir.ptr<!s32i, addrspace(offload_global)>
44+ // CIR: cir.cast address_space %[[x]] : !cir.ptr<!s32i, addrspace(offload_global)> -> !cir.ptr<!cir.vector<!s8i x 4>, addrspace(offload_local)>
45+ // LLVM: define spir_func ptr addrspace(3) @f4_ptr(ptr addrspace(1) readnone captures(ret: address, provenance) %[[x:.*]])
46+ // LLVM: %[[astype:.*]] = addrspacecast ptr addrspace(1) %[[x]] to ptr addrspace(3)
47+ // LLVM-NOT: shufflevector
48+ // LLVM: ret ptr addrspace(3) %[[astype]]
49+ // OG-LLVM: define spir_func ptr addrspace(3) @f4_ptr(ptr addrspace(1) noundef readnone captures(ret: address, provenance) %[[x:.*]])
50+ // OG-LLVM: %[[astype:.*]] = addrspacecast ptr addrspace(1) %[[x]] to ptr addrspace(3)
51+ // OG-LLVM-NOT: shufflevector
52+ // OG-LLVM: ret ptr addrspace(3) %[[astype]]
53+ __local char4 * f4_ptr (__global int * x ) {
54+ return __builtin_astype (x , __local char4 * );
4355}
0 commit comments