1 ; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
3 ; CHECK-DAG: OpDecorate %[[#Memset_p0i32:]] LinkageAttributes "spirv.llvm_memset_p0_i32" Export
4 ; CHECK-DAG: OpDecorate %[[#Memset_p3i32:]] LinkageAttributes "spirv.llvm_memset_p3_i32" Export
5 ; CHECK-DAG: OpDecorate %[[#Memset_p1i64:]] LinkageAttributes "spirv.llvm_memset_p1_i64" Export
6 ; CHECK-DAG: OpDecorate %[[#Memset_p1i64:]] LinkageAttributes "spirv.llvm_memset_p1_i64.volatile" Export
8 ; CHECK-DAG: %[[#Int8:]] = OpTypeInt 8 0
9 ; CHECK-DAG: %[[#Int32:]] = OpTypeInt 32 0
10 ; CHECK-DAG: %[[#Int64:]] = OpTypeInt 64 0
11 ; CHECK-DAG: %[[#Void:]] = OpTypeVoid
12 ; CHECK-DAG: %[[#Int8Ptr:]] = OpTypePointer Generic %[[#Int8]]
14 ; CHECK-DAG: %[[#Const4:]] = OpConstant %[[#Int32]] 4
15 ; CHECK: %[[#Int8x4:]] = OpTypeArray %[[#Int8]] %[[#Const4]]
17 ; CHECK-DAG: %[[#Const12:]] = OpConstant %[[#Int32]] 12
18 ; CHECK: %[[#Int8x12:]] = OpTypeArray %[[#Int8]] %[[#Const12]]
20 ; CHECK-DAG: %[[#Const21:]] = OpConstant %[[#Int8]] 21
21 ; CHECK-DAG: %[[#False:]] = OpConstantFalse %[[#]]
22 ; CHECK-DAG: %[[#ConstComp:]] = OpConstantComposite %[[#Int8x4]] %[[#Const21]] %[[#Const21]] %[[#Const21]] %[[#Const21]]
23 ; CHECK-DAG: %[[#ConstNull:]] = OpConstantNull %[[#Int8x12]]
24 ; CHECK: %[[#VarComp:]] = OpVariable %[[#]] UniformConstant %[[#ConstComp]]
25 ; CHECK: %[[#VarNull:]] = OpVariable %[[#]] UniformConstant %[[#ConstNull]]
27 ; CHECK-DAG: %[[#Int8PtrConst:]] = OpTypePointer UniformConstant %[[#Int8]]
28 ; CHECK: %[[#Target:]] = OpBitcast %[[#Int8Ptr]] %[[#]]
29 ; CHECK: %[[#Source:]] = OpBitcast %[[#Int8PtrConst]] %[[#VarNull]]
30 ; CHECK: OpCopyMemorySized %[[#Target]] %[[#Source]] %[[#Const12]] Aligned 4
32 ; CHECK: %[[#SourceComp:]] = OpBitcast %[[#Int8PtrConst]] %[[#VarComp]]
33 ; CHECK: OpCopyMemorySized %[[#]] %[[#SourceComp]] %[[#Const4]] Aligned 4
35 ; CHECK-SPIRV: %[[#]] = OpFunctionCall %[[#]] %[[#Memset_p0i32]] %[[#]] %[[#]] %[[#]] %[[#False]]
37 ; CHECK: %[[#Memset_p0i32]] = OpFunction %[[#]]
38 ; CHECK: %[[#Dest:]] = OpFunctionParameter %[[#]]
39 ; CHECK: %[[#Value:]] = OpFunctionParameter %[[#]]
40 ; CHECK: %[[#Len:]] = OpFunctionParameter %[[#]]
41 ; CHECK: %[[#Volatile:]] = OpFunctionParameter %[[#]]
43 ; CHECK: %[[#Entry:]] = OpLabel
44 ; CHECK: %[[#IsZeroLen:]] = OpIEqual %[[#]] %[[#Zero:]] %[[#Len]]
45 ; CHECK: OpBranchConditional %[[#IsZeroLen]] %[[#End:]] %[[#WhileBody:]]
47 ; CHECK: %[[#WhileBody]] = OpLabel
48 ; CHECK: %[[#Offset:]] = OpPhi %[[#]] %[[#Zero]] %[[#Entry]] %[[#OffsetInc:]] %[[#WhileBody]]
49 ; CHECK: %[[#Ptr:]] = OpInBoundsPtrAccessChain %[[#]] %[[#Dest]] %[[#Offset]]
50 ; CHECK: OpStore %[[#Ptr]] %[[#Value]] Aligned 1
51 ; CHECK: %[[#OffsetInc]] = OpIAdd %[[#]] %[[#Offset]] %[[#One:]]
52 ; CHECK: %[[#NotEnd:]] = OpULessThan %[[#]] %[[#OffsetInc]] %[[#Len]]
53 ; CHECK: OpBranchConditional %[[#NotEnd]] %[[#WhileBody]] %[[#End]]
55 ; CHECK: %[[#End]] = OpLabel
58 ; CHECK: OpFunctionEnd
60 %struct.S1 = type { i32, i32, i32 }
62 define spir_func void @_Z5foo11v(%struct.S1 addrspace(4)* noalias nocapture sret(%struct.S1 addrspace(4)*) %agg.result, i32 %s1, i64 %s2, i8 %v) {
64 %x.bc = bitcast [4 x i8]* %x to i8*
65 %a = bitcast %struct.S1 addrspace(4)* %agg.result to i8 addrspace(4)*
66 tail call void @llvm.memset.p4i8.i32(i8 addrspace(4)* align 4 %a, i8 0, i32 12, i1 false)
67 tail call void @llvm.memset.p0i8.i32(i8* align 4 %x.bc, i8 21, i32 4, i1 false)
70 tail call void @llvm.memset.p0i8.i32(i8* align 4 %x.bc, i8 %v, i32 3, i1 false)
72 ;; non-const value and size
73 tail call void @llvm.memset.p0i8.i32(i8* align 4 %x.bc, i8 %v, i32 %s1, i1 false)
75 ;; Address spaces, non-const value and size
76 %b = addrspacecast i8 addrspace(4)* %a to i8 addrspace(3)*
77 tail call void @llvm.memset.p3i8.i32(i8 addrspace(3)* align 4 %b, i8 %v, i32 %s1, i1 false)
78 %c = addrspacecast i8 addrspace(4)* %a to i8 addrspace(1)*
79 tail call void @llvm.memset.p1i8.i64(i8 addrspace(1)* align 4 %c, i8 %v, i64 %s2, i1 false)
82 tail call void @llvm.memset.p1i8.i64(i8 addrspace(1)* align 4 %c, i8 %v, i64 %s2, i1 true)
86 declare void @llvm.memset.p4i8.i32(i8 addrspace(4)* nocapture, i8, i32, i1)
88 declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i1)
90 declare void @llvm.memset.p3i8.i32(i8 addrspace(3)*, i8, i32, i1)
92 declare void @llvm.memset.p1i8.i64(i8 addrspace(1)*, i8, i64, i1)