1 ; RUN: opt -loop-vectorize -enable-arm-maskedldst < %s -S -o - | FileCheck %s
3 target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
4 target triple = "thumbv8.1-m.main-none-eabi"
6 ; CHECK-LABEL: test_i32_align4
7 ; CHECK: call void @llvm.masked.store.v4i32.p0v4i32
8 define void @test_i32_align4(i32* nocapture %A, i32 %n) #0 {
10 %cmp12 = icmp sgt i32 %n, 0
11 br i1 %cmp12, label %for.body.preheader, label %for.cond.cleanup
13 for.body.preheader: ; preds = %entry
16 for.body: ; preds = %for.body.preheader, %for.inc
17 %i.013 = phi i32 [ %inc, %for.inc ], [ 0, %for.body.preheader ]
18 %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.013
19 %0 = load i32, i32* %arrayidx, align 4
21 %1 = icmp ult i32 %.off, 19
22 br i1 %1, label %if.then, label %for.inc
24 if.then: ; preds = %for.body
25 store i32 0, i32* %arrayidx, align 4
28 for.inc: ; preds = %for.body, %if.then
29 %inc = add nuw nsw i32 %i.013, 1
30 %exitcond = icmp eq i32 %inc, %n
31 br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body
33 for.cond.cleanup.loopexit: ; preds = %for.inc
34 br label %for.cond.cleanup
36 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
40 ; CHECK-LABEL: test_i32_align2
41 ; CHECK-NOT: call void @llvm.masked.store
42 define void @test_i32_align2(i32* nocapture %A, i32 %n) #0 {
44 %cmp12 = icmp sgt i32 %n, 0
45 br i1 %cmp12, label %for.body.preheader, label %for.cond.cleanup
47 for.body.preheader: ; preds = %entry
50 for.body: ; preds = %for.body.preheader, %for.inc
51 %i.013 = phi i32 [ %inc, %for.inc ], [ 0, %for.body.preheader ]
52 %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.013
53 %0 = load i32, i32* %arrayidx, align 2
55 %1 = icmp ult i32 %.off, 19
56 br i1 %1, label %if.then, label %for.inc
58 if.then: ; preds = %for.body
59 store i32 0, i32* %arrayidx, align 2
62 for.inc: ; preds = %for.body, %if.then
63 %inc = add nuw nsw i32 %i.013, 1
64 %exitcond = icmp eq i32 %inc, %n
65 br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body
67 for.cond.cleanup.loopexit: ; preds = %for.inc
68 br label %for.cond.cleanup
70 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
74 ; CHECK-LABEL: test_i32_noalign
75 ; CHECK: call void @llvm.masked.store.v4i32.p0v4i32
76 define void @test_i32_noalign(i32* nocapture %A, i32 %n) #0 {
78 %cmp12 = icmp sgt i32 %n, 0
79 br i1 %cmp12, label %for.body.preheader, label %for.cond.cleanup
81 for.body.preheader: ; preds = %entry
84 for.body: ; preds = %for.body.preheader, %for.inc
85 %i.013 = phi i32 [ %inc, %for.inc ], [ 0, %for.body.preheader ]
86 %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.013
87 %0 = load i32, i32* %arrayidx
89 %1 = icmp ult i32 %.off, 19
90 br i1 %1, label %if.then, label %for.inc
92 if.then: ; preds = %for.body
93 store i32 0, i32* %arrayidx
96 for.inc: ; preds = %for.body, %if.then
97 %inc = add nuw nsw i32 %i.013, 1
98 %exitcond = icmp eq i32 %inc, %n
99 br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body
101 for.cond.cleanup.loopexit: ; preds = %for.inc
102 br label %for.cond.cleanup
104 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
108 ; CHECK-LABEL: test_i16_align2
109 ; CHECK: call void @llvm.masked.store.v8i16.p0v8i16
110 define void @test_i16_align2(i16* nocapture %A, i32 %n) #0 {
112 %cmp12 = icmp sgt i32 %n, 0
113 br i1 %cmp12, label %for.body.preheader, label %for.cond.cleanup
115 for.body.preheader: ; preds = %entry
118 for.body: ; preds = %for.body.preheader, %for.inc
119 %i.013 = phi i32 [ %inc, %for.inc ], [ 0, %for.body.preheader ]
120 %arrayidx = getelementptr inbounds i16, i16* %A, i32 %i.013
121 %0 = load i16, i16* %arrayidx, align 2
122 %.off = add i16 %0, 9
123 %1 = icmp ult i16 %.off, 19
124 br i1 %1, label %if.then, label %for.inc
126 if.then: ; preds = %for.body
127 store i16 0, i16* %arrayidx, align 2
130 for.inc: ; preds = %for.body, %if.then
131 %inc = add nuw nsw i32 %i.013, 1
132 %exitcond = icmp eq i32 %inc, %n
133 br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body
135 for.cond.cleanup.loopexit: ; preds = %for.inc
136 br label %for.cond.cleanup
138 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
142 ; CHECK-LABEL: test_i16_align1
143 ; CHECK-NOT: call void @llvm.masked.store
144 define void @test_i16_align1(i16* nocapture %A, i32 %n) #0 {
146 %cmp12 = icmp sgt i32 %n, 0
147 br i1 %cmp12, label %for.body.preheader, label %for.cond.cleanup
149 for.body.preheader: ; preds = %entry
152 for.body: ; preds = %for.body.preheader, %for.inc
153 %i.013 = phi i32 [ %inc, %for.inc ], [ 0, %for.body.preheader ]
154 %arrayidx = getelementptr inbounds i16, i16* %A, i32 %i.013
155 %0 = load i16, i16* %arrayidx, align 1
156 %.off = add i16 %0, 9
157 %1 = icmp ult i16 %.off, 19
158 br i1 %1, label %if.then, label %for.inc
160 if.then: ; preds = %for.body
161 store i16 0, i16* %arrayidx, align 1
164 for.inc: ; preds = %for.body, %if.then
165 %inc = add nuw nsw i32 %i.013, 1
166 %exitcond = icmp eq i32 %inc, %n
167 br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body
169 for.cond.cleanup.loopexit: ; preds = %for.inc
170 br label %for.cond.cleanup
172 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
176 attributes #0 = { "target-features"="+mve" }