1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=memcpyopt,dce -S -verify-memoryssa | FileCheck %s
5 ; Check this test is not transformed into memset, or cause a compiler warning
6 ; warning: Compiler has made implicit assumption that TypeSize is not scalable. This may or may not lead to broken code.
8 define void @foo(ptr %p) {
10 ; CHECK-NEXT: store <vscale x 16 x i8> zeroinitializer, ptr [[P:%.*]], align 16
11 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr <vscale x 16 x i8>, ptr [[P:%.*]], i64 1
12 ; CHECK-NEXT: store <vscale x 16 x i8> zeroinitializer, ptr [[TMP1]], align 16
13 ; CHECK-NEXT: ret void
15 store <vscale x 16 x i8> zeroinitializer, ptr %p
16 %tmp1 = getelementptr <vscale x 16 x i8>, ptr %p, i64 1
17 store <vscale x 16 x i8> zeroinitializer, ptr %tmp1
23 define void @memset_vscale_index_zero(ptr %p, i8 %z) {
24 ; CHECK-LABEL: @memset_vscale_index_zero(
25 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[P:%.*]], i8 [[Z:%.*]], i64 17, i1 false)
26 ; CHECK-NEXT: ret void
29 %tmp1 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 1
30 store i8 %z, ptr %tmp1
31 %tmp2 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 2
32 store i8 %z, ptr %tmp2
33 %tmp3 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 3
34 store i8 %z, ptr %tmp3
35 %tmp4 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 4
36 store i8 %z, ptr %tmp4
37 %tmp5 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 5
38 store i8 %z, ptr %tmp5
39 %tmp6 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 6
40 store i8 %z, ptr %tmp6
41 %tmp7 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 7
42 store i8 %z, ptr %tmp7
43 %tmp8 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 8
44 store i8 %z, ptr %tmp8
45 %tmp9 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 9
46 store i8 %z, ptr %tmp9
47 %tmp10 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 10
48 store i8 %z, ptr %tmp10
49 %tmp11 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 11
50 store i8 %z, ptr %tmp11
51 %tmp12 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 12
52 store i8 %z, ptr %tmp12
53 %tmp13 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 13
54 store i8 %z, ptr %tmp13
55 %tmp14 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 14
56 store i8 %z, ptr %tmp14
57 %tmp15 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 15
58 store i8 %z, ptr %tmp15
59 %tmp16 = getelementptr <vscale x 16 x i8>, ptr %p, i32 0, i32 16
60 store i8 %z, ptr %tmp16
64 define void @memset_vscale_index_nonzero(ptr %p, i8 %z) {
65 ; CHECK-LABEL: @memset_vscale_index_nonzero(
66 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr <vscale x 16 x i8>, ptr [[P:%.*]], i32 1, i32 0
67 ; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr align 1 [[TMP0]], i8 [[Z:%.*]], i64 17, i1 false)
68 ; CHECK-NEXT: ret void
70 %tmp0 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 0
71 store i8 %z, ptr %tmp0
72 %tmp1 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 1
73 store i8 %z, ptr %tmp1
74 %tmp2 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 2
75 store i8 %z, ptr %tmp2
76 %tmp3 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 3
77 store i8 %z, ptr %tmp3
78 %tmp4 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 4
79 store i8 %z, ptr %tmp4
80 %tmp5 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 5
81 store i8 %z, ptr %tmp5
82 %tmp6 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 6
83 store i8 %z, ptr %tmp6
84 %tmp7 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 7
85 store i8 %z, ptr %tmp7
86 %tmp8 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 8
87 store i8 %z, ptr %tmp8
88 %tmp9 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 9
89 store i8 %z, ptr %tmp9
90 %tmp10 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 10
91 store i8 %z, ptr %tmp10
92 %tmp11 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 11
93 store i8 %z, ptr %tmp11
94 %tmp12 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 12
95 store i8 %z, ptr %tmp12
96 %tmp13 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 13
97 store i8 %z, ptr %tmp13
98 %tmp14 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 14
99 store i8 %z, ptr %tmp14
100 %tmp15 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 15
101 store i8 %z, ptr %tmp15
102 %tmp16 = getelementptr <vscale x 16 x i8>, ptr %p, i32 1, i32 16
103 store i8 %z, ptr %tmp16