1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -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(i8* %p) {
10 ; CHECK-NEXT: [[A:%.*]] = bitcast i8* [[P:%.*]] to <vscale x 16 x i8>*
11 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* [[A]], i64 0
12 ; CHECK-NEXT: store <vscale x 16 x i8> zeroinitializer, <vscale x 16 x i8>* [[TMP0]], align 16
13 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* [[A]], i64 1
14 ; CHECK-NEXT: store <vscale x 16 x i8> zeroinitializer, <vscale x 16 x i8>* [[TMP1]], align 16
15 ; CHECK-NEXT: ret void
17 %a = bitcast i8* %p to <vscale x 16 x i8>*
18 %tmp0 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i64 0
19 store <vscale x 16 x i8> zeroinitializer, <vscale x 16 x i8>* %tmp0
20 %tmp1 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i64 1
21 store <vscale x 16 x i8> zeroinitializer, <vscale x 16 x i8>* %tmp1
27 define void @memset_vscale_index_zero(i8* %p, i8 %z) {
28 ; CHECK-LABEL: @memset_vscale_index_zero(
29 ; CHECK-NEXT: [[A:%.*]] = bitcast i8* [[P:%.*]] to <vscale x 16 x i8>*
30 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* [[A]], i32 0, i32 0
31 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 1 [[TMP0]], i8 [[Z:%.*]], i64 17, i1 false)
32 ; CHECK-NEXT: ret void
34 %a = bitcast i8* %p to <vscale x 16 x i8>*
35 %tmp0 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 0
36 store i8 %z, i8* %tmp0
37 %tmp1 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 1
38 store i8 %z, i8* %tmp1
39 %tmp2 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 2
40 store i8 %z, i8* %tmp2
41 %tmp3 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 3
42 store i8 %z, i8* %tmp3
43 %tmp4 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 4
44 store i8 %z, i8* %tmp4
45 %tmp5 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 5
46 store i8 %z, i8* %tmp5
47 %tmp6 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 6
48 store i8 %z, i8* %tmp6
49 %tmp7 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 7
50 store i8 %z, i8* %tmp7
51 %tmp8 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 8
52 store i8 %z, i8* %tmp8
53 %tmp9 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 9
54 store i8 %z, i8* %tmp9
55 %tmp10 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 10
56 store i8 %z, i8* %tmp10
57 %tmp11 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 11
58 store i8 %z, i8* %tmp11
59 %tmp12 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 12
60 store i8 %z, i8* %tmp12
61 %tmp13 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 13
62 store i8 %z, i8* %tmp13
63 %tmp14 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 14
64 store i8 %z, i8* %tmp14
65 %tmp15 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 15
66 store i8 %z, i8* %tmp15
67 %tmp16 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 0, i32 16
68 store i8 %z, i8* %tmp16
72 define void @memset_vscale_index_nonzero(i8* %p, i8 %z) {
73 ; CHECK-LABEL: @memset_vscale_index_nonzero(
74 ; CHECK-NEXT: [[A:%.*]] = bitcast i8* [[P:%.*]] to <vscale x 16 x i8>*
75 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* [[A]], i32 1, i32 0
76 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 1 [[TMP0]], i8 [[Z:%.*]], i64 17, i1 false)
77 ; CHECK-NEXT: ret void
79 %a = bitcast i8* %p to <vscale x 16 x i8>*
80 %tmp0 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 0
81 store i8 %z, i8* %tmp0
82 %tmp1 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 1
83 store i8 %z, i8* %tmp1
84 %tmp2 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 2
85 store i8 %z, i8* %tmp2
86 %tmp3 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 3
87 store i8 %z, i8* %tmp3
88 %tmp4 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 4
89 store i8 %z, i8* %tmp4
90 %tmp5 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 5
91 store i8 %z, i8* %tmp5
92 %tmp6 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 6
93 store i8 %z, i8* %tmp6
94 %tmp7 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 7
95 store i8 %z, i8* %tmp7
96 %tmp8 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 8
97 store i8 %z, i8* %tmp8
98 %tmp9 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 9
99 store i8 %z, i8* %tmp9
100 %tmp10 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 10
101 store i8 %z, i8* %tmp10
102 %tmp11 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 11
103 store i8 %z, i8* %tmp11
104 %tmp12 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 12
105 store i8 %z, i8* %tmp12
106 %tmp13 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 13
107 store i8 %z, i8* %tmp13
108 %tmp14 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 14
109 store i8 %z, i8* %tmp14
110 %tmp15 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 15
111 store i8 %z, i8* %tmp15
112 %tmp16 = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %a, i32 1, i32 16
113 store i8 %z, i8* %tmp16