1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -mtriple=amdgcn-- -pre-isel-intrinsic-lowering -mem-intrinsic-expand-size=8 %s | FileCheck -check-prefix=OPT8 %s
3 ; RUN: opt -S -mtriple=amdgcn-- -pre-isel-intrinsic-lowering -mem-intrinsic-expand-size=4 %s | FileCheck -check-prefix=OPT4 %s
4 ; RUN: opt -S -mtriple=amdgcn-- -pre-isel-intrinsic-lowering -mem-intrinsic-expand-size=0 %s | FileCheck -check-prefix=OPT0 %s
5 ; RUN: opt -S -mtriple=amdgcn-- -pre-isel-intrinsic-lowering -mem-intrinsic-expand-size=-1 %s | FileCheck -check-prefix=OPT_NEG %s
7 ; Test the -mem-intrinsic-expand-size flag works.
9 ; Make sure we can always eliminate the intrinsic, even at 0.
10 define amdgpu_kernel void @memset_size_0(ptr addrspace(1) %dst, i8 %val) {
11 ; OPT8-LABEL: @memset_size_0(
12 ; OPT8-NEXT: call void @llvm.memset.p1.i64(ptr addrspace(1) [[DST:%.*]], i8 [[VAL:%.*]], i64 0, i1 false)
15 ; OPT4-LABEL: @memset_size_0(
16 ; OPT4-NEXT: call void @llvm.memset.p1.i64(ptr addrspace(1) [[DST:%.*]], i8 [[VAL:%.*]], i64 0, i1 false)
19 ; OPT0-LABEL: @memset_size_0(
20 ; OPT0-NEXT: br i1 true, label [[SPLIT:%.*]], label [[LOADSTORELOOP:%.*]]
21 ; OPT0: loadstoreloop:
22 ; OPT0-NEXT: [[TMP1:%.*]] = phi i64 [ 0, [[TMP0:%.*]] ], [ [[TMP3:%.*]], [[LOADSTORELOOP]] ]
23 ; OPT0-NEXT: [[TMP2:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[DST:%.*]], i64 [[TMP1]]
24 ; OPT0-NEXT: store i8 [[VAL:%.*]], ptr addrspace(1) [[TMP2]], align 1
25 ; OPT0-NEXT: [[TMP3]] = add i64 [[TMP1]], 1
26 ; OPT0-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 0
27 ; OPT0-NEXT: br i1 [[TMP4]], label [[LOADSTORELOOP]], label [[SPLIT]]
31 ; OPT_NEG-LABEL: @memset_size_0(
32 ; OPT_NEG-NEXT: call void @llvm.memset.p1.i64(ptr addrspace(1) [[DST:%.*]], i8 [[VAL:%.*]], i64 0, i1 false)
33 ; OPT_NEG-NEXT: ret void
35 call void @llvm.memset.p1.i64(ptr addrspace(1) %dst, i8 %val, i64 0, i1 false)
39 define amdgpu_kernel void @memset_size_4(ptr addrspace(1) %dst, i8 %val) {
40 ; OPT8-LABEL: @memset_size_4(
41 ; OPT8-NEXT: call void @llvm.memset.p1.i64(ptr addrspace(1) [[DST:%.*]], i8 [[VAL:%.*]], i64 4, i1 false)
44 ; OPT4-LABEL: @memset_size_4(
45 ; OPT4-NEXT: call void @llvm.memset.p1.i64(ptr addrspace(1) [[DST:%.*]], i8 [[VAL:%.*]], i64 4, i1 false)
48 ; OPT0-LABEL: @memset_size_4(
49 ; OPT0-NEXT: br i1 false, label [[SPLIT:%.*]], label [[LOADSTORELOOP:%.*]]
50 ; OPT0: loadstoreloop:
51 ; OPT0-NEXT: [[TMP1:%.*]] = phi i64 [ 0, [[TMP0:%.*]] ], [ [[TMP3:%.*]], [[LOADSTORELOOP]] ]
52 ; OPT0-NEXT: [[TMP2:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[DST:%.*]], i64 [[TMP1]]
53 ; OPT0-NEXT: store i8 [[VAL:%.*]], ptr addrspace(1) [[TMP2]], align 1
54 ; OPT0-NEXT: [[TMP3]] = add i64 [[TMP1]], 1
55 ; OPT0-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 4
56 ; OPT0-NEXT: br i1 [[TMP4]], label [[LOADSTORELOOP]], label [[SPLIT]]
60 ; OPT_NEG-LABEL: @memset_size_4(
61 ; OPT_NEG-NEXT: call void @llvm.memset.p1.i64(ptr addrspace(1) [[DST:%.*]], i8 [[VAL:%.*]], i64 4, i1 false)
62 ; OPT_NEG-NEXT: ret void
64 call void @llvm.memset.p1.i64(ptr addrspace(1) %dst, i8 %val, i64 4, i1 false)
68 define amdgpu_kernel void @memset_size_8(ptr addrspace(1) %dst, i8 %val) {
69 ; OPT8-LABEL: @memset_size_8(
70 ; OPT8-NEXT: call void @llvm.memset.p1.i64(ptr addrspace(1) [[DST:%.*]], i8 [[VAL:%.*]], i64 8, i1 false)
73 ; OPT4-LABEL: @memset_size_8(
74 ; OPT4-NEXT: br i1 false, label [[SPLIT:%.*]], label [[LOADSTORELOOP:%.*]]
75 ; OPT4: loadstoreloop:
76 ; OPT4-NEXT: [[TMP1:%.*]] = phi i64 [ 0, [[TMP0:%.*]] ], [ [[TMP3:%.*]], [[LOADSTORELOOP]] ]
77 ; OPT4-NEXT: [[TMP2:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[DST:%.*]], i64 [[TMP1]]
78 ; OPT4-NEXT: store i8 [[VAL:%.*]], ptr addrspace(1) [[TMP2]], align 1
79 ; OPT4-NEXT: [[TMP3]] = add i64 [[TMP1]], 1
80 ; OPT4-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 8
81 ; OPT4-NEXT: br i1 [[TMP4]], label [[LOADSTORELOOP]], label [[SPLIT]]
85 ; OPT0-LABEL: @memset_size_8(
86 ; OPT0-NEXT: br i1 false, label [[SPLIT:%.*]], label [[LOADSTORELOOP:%.*]]
87 ; OPT0: loadstoreloop:
88 ; OPT0-NEXT: [[TMP1:%.*]] = phi i64 [ 0, [[TMP0:%.*]] ], [ [[TMP3:%.*]], [[LOADSTORELOOP]] ]
89 ; OPT0-NEXT: [[TMP2:%.*]] = getelementptr inbounds i8, ptr addrspace(1) [[DST:%.*]], i64 [[TMP1]]
90 ; OPT0-NEXT: store i8 [[VAL:%.*]], ptr addrspace(1) [[TMP2]], align 1
91 ; OPT0-NEXT: [[TMP3]] = add i64 [[TMP1]], 1
92 ; OPT0-NEXT: [[TMP4:%.*]] = icmp ult i64 [[TMP3]], 8
93 ; OPT0-NEXT: br i1 [[TMP4]], label [[LOADSTORELOOP]], label [[SPLIT]]
97 ; OPT_NEG-LABEL: @memset_size_8(
98 ; OPT_NEG-NEXT: call void @llvm.memset.p1.i64(ptr addrspace(1) [[DST:%.*]], i8 [[VAL:%.*]], i64 8, i1 false)
99 ; OPT_NEG-NEXT: ret void
101 call void @llvm.memset.p1.i64(ptr addrspace(1) %dst, i8 %val, i64 8, i1 false)
105 declare void @llvm.memset.p1.i64(ptr addrspace(1) nocapture writeonly, i8, i64, i1 immarg) #0
107 attributes #0 = { argmemonly nounwind willreturn writeonly }