1; RUN: opt -passes=loop-vectorize < %s -S -o - | FileCheck %s 2 3target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" 4target triple = "thumbv8.1m.main-none-eabi" 5 6; CHECK-LABEL: test_i32_align4 7; CHECK: call void @llvm.masked.store.v4i32.p0 8define void @test_i32_align4(ptr nocapture %A, i32 %n) #0 { 9entry: 10 %cmp12 = icmp sgt i32 %n, 0 11 br i1 %cmp12, label %for.body.preheader, label %for.cond.cleanup 12 13for.body.preheader: ; preds = %entry 14 br label %for.body 15 16for.body: ; preds = %for.body.preheader, %for.inc 17 %i.013 = phi i32 [ %inc, %for.inc ], [ 0, %for.body.preheader ] 18 %arrayidx = getelementptr inbounds i32, ptr %A, i32 %i.013 19 %0 = load i32, ptr %arrayidx, align 4 20 %.off = add i32 %0, 9 21 %1 = icmp ult i32 %.off, 19 22 br i1 %1, label %if.then, label %for.inc 23 24if.then: ; preds = %for.body 25 store i32 0, ptr %arrayidx, align 4 26 br label %for.inc 27 28for.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 32 33for.cond.cleanup.loopexit: ; preds = %for.inc 34 br label %for.cond.cleanup 35 36for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry 37 ret void 38} 39 40; CHECK-LABEL: test_i32_align2 41; CHECK-NOT: call void @llvm.masked.store 42define void @test_i32_align2(ptr nocapture %A, i32 %n) #0 { 43entry: 44 %cmp12 = icmp sgt i32 %n, 0 45 br i1 %cmp12, label %for.body.preheader, label %for.cond.cleanup 46 47for.body.preheader: ; preds = %entry 48 br label %for.body 49 50for.body: ; preds = %for.body.preheader, %for.inc 51 %i.013 = phi i32 [ %inc, %for.inc ], [ 0, %for.body.preheader ] 52 %arrayidx = getelementptr inbounds i32, ptr %A, i32 %i.013 53 %0 = load i32, ptr %arrayidx, align 2 54 %.off = add i32 %0, 9 55 %1 = icmp ult i32 %.off, 19 56 br i1 %1, label %if.then, label %for.inc 57 58if.then: ; preds = %for.body 59 store i32 0, ptr %arrayidx, align 2 60 br label %for.inc 61 62for.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 66 67for.cond.cleanup.loopexit: ; preds = %for.inc 68 br label %for.cond.cleanup 69 70for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry 71 ret void 72} 73 74; CHECK-LABEL: test_i32_noalign 75; CHECK: call void @llvm.masked.store.v4i32.p0 76define void @test_i32_noalign(ptr nocapture %A, i32 %n) #0 { 77entry: 78 %cmp12 = icmp sgt i32 %n, 0 79 br i1 %cmp12, label %for.body.preheader, label %for.cond.cleanup 80 81for.body.preheader: ; preds = %entry 82 br label %for.body 83 84for.body: ; preds = %for.body.preheader, %for.inc 85 %i.013 = phi i32 [ %inc, %for.inc ], [ 0, %for.body.preheader ] 86 %arrayidx = getelementptr inbounds i32, ptr %A, i32 %i.013 87 %0 = load i32, ptr %arrayidx 88 %.off = add i32 %0, 9 89 %1 = icmp ult i32 %.off, 19 90 br i1 %1, label %if.then, label %for.inc 91 92if.then: ; preds = %for.body 93 store i32 0, ptr %arrayidx 94 br label %for.inc 95 96for.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 100 101for.cond.cleanup.loopexit: ; preds = %for.inc 102 br label %for.cond.cleanup 103 104for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry 105 ret void 106} 107 108; CHECK-LABEL: test_i16_align2 109; CHECK: call void @llvm.masked.store.v8i16.p0 110define void @test_i16_align2(ptr nocapture %A, i32 %n) #0 { 111entry: 112 %cmp12 = icmp sgt i32 %n, 0 113 br i1 %cmp12, label %for.body.preheader, label %for.cond.cleanup 114 115for.body.preheader: ; preds = %entry 116 br label %for.body 117 118for.body: ; preds = %for.body.preheader, %for.inc 119 %i.013 = phi i32 [ %inc, %for.inc ], [ 0, %for.body.preheader ] 120 %arrayidx = getelementptr inbounds i16, ptr %A, i32 %i.013 121 %0 = load i16, ptr %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 125 126if.then: ; preds = %for.body 127 store i16 0, ptr %arrayidx, align 2 128 br label %for.inc 129 130for.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 134 135for.cond.cleanup.loopexit: ; preds = %for.inc 136 br label %for.cond.cleanup 137 138for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry 139 ret void 140} 141 142; CHECK-LABEL: test_i16_align1 143; CHECK-NOT: call void @llvm.masked.store 144define void @test_i16_align1(ptr nocapture %A, i32 %n) #0 { 145entry: 146 %cmp12 = icmp sgt i32 %n, 0 147 br i1 %cmp12, label %for.body.preheader, label %for.cond.cleanup 148 149for.body.preheader: ; preds = %entry 150 br label %for.body 151 152for.body: ; preds = %for.body.preheader, %for.inc 153 %i.013 = phi i32 [ %inc, %for.inc ], [ 0, %for.body.preheader ] 154 %arrayidx = getelementptr inbounds i16, ptr %A, i32 %i.013 155 %0 = load i16, ptr %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 159 160if.then: ; preds = %for.body 161 store i16 0, ptr %arrayidx, align 1 162 br label %for.inc 163 164for.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 168 169for.cond.cleanup.loopexit: ; preds = %for.inc 170 br label %for.cond.cleanup 171 172for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry 173 ret void 174} 175 176attributes #0 = { "target-features"="+mve" } 177