1; RUN: opt < %s -analyze -basicaa -da | FileCheck %s 2 3; ModuleID = 'WeakZeroDstSIV.bc' 4target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" 5target triple = "x86_64-apple-macosx10.6.0" 6 7 8;; for (int i = 0; i < N; i++) { 9;; A[i] = 1; 10;; A[0] = 2; 11 12define void @dstzero(i32* nocapture %A, i32 %N) { 13entry: 14 %cmp6 = icmp sgt i32 %N, 0 15 br i1 %cmp6, label %for.body, label %for.cond.cleanup 16 17; CHECK: da analyze - none! 18; CHECK: da analyze - output [p<=|<]! 19; CHECK: da analyze - consistent output [S]! 20 21for.body: ; preds = %entry, %for.body 22 %i.07 = phi i32 [ %add, %for.body ], [ 0, %entry ] 23 %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.07 24 store i32 0, i32* %arrayidx, align 4 25 store i32 1, i32* %A, align 4 26 %add = add nuw nsw i32 %i.07, 1 27 %exitcond = icmp eq i32 %add, %N 28 br i1 %exitcond, label %for.cond.cleanup, label %for.body 29 30for.cond.cleanup: ; preds = %for.body, %entry 31 ret void 32} 33 34 35 36 37;; for (long unsigned i = 0; i < 30; i++) { 38;; A[2*i + 10] = i; 39;; *B++ = A[10]; 40 41define void @weakzerodst0(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp { 42entry: 43 br label %for.body 44 45; CHECK: da analyze - none! 46; CHECK: da analyze - flow [p<=|<]! 47; CHECK: da analyze - confused! 48; CHECK: da analyze - consistent input [S]! 49; CHECK: da analyze - confused! 50; CHECK: da analyze - none! 51 52for.body: ; preds = %entry, %for.body 53 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ] 54 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ] 55 %conv = trunc i64 %i.02 to i32 56 %mul = shl i64 %i.02, 1 57 %add = add i64 %mul, 10 58 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add 59 store i32 %conv, i32* %arrayidx, align 4 60 %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 10 61 %0 = load i32, i32* %arrayidx1, align 4 62 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1 63 store i32 %0, i32* %B.addr.01, align 4 64 %inc = add i64 %i.02, 1 65 %exitcond = icmp ne i64 %inc, 30 66 br i1 %exitcond, label %for.body, label %for.end 67 68for.end: ; preds = %for.body 69 ret void 70} 71 72 73;; for (long unsigned i = 0; i < n; i++) { 74;; A[n*i + 10] = i; 75;; *B++ = A[10]; 76 77define void @weakzerodst1(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp { 78entry: 79 %cmp1 = icmp eq i64 %n, 0 80 br i1 %cmp1, label %for.end, label %for.body.preheader 81 82; CHECK: da analyze - none! 83; CHECK: da analyze - flow [p<=|<]! 84; CHECK: da analyze - confused! 85; CHECK: da analyze - consistent input [S]! 86; CHECK: da analyze - confused! 87; CHECK: da analyze - none! 88 89for.body.preheader: ; preds = %entry 90 br label %for.body 91 92for.body: ; preds = %for.body.preheader, %for.body 93 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ] 94 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ] 95 %conv = trunc i64 %i.03 to i32 96 %mul = mul i64 %i.03, %n 97 %add = add i64 %mul, 10 98 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add 99 store i32 %conv, i32* %arrayidx, align 4 100 %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 10 101 %0 = load i32, i32* %arrayidx1, align 4 102 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1 103 store i32 %0, i32* %B.addr.02, align 4 104 %inc = add i64 %i.03, 1 105 %exitcond = icmp ne i64 %inc, %n 106 br i1 %exitcond, label %for.body, label %for.end.loopexit 107 108for.end.loopexit: ; preds = %for.body 109 br label %for.end 110 111for.end: ; preds = %for.end.loopexit, %entry 112 ret void 113} 114 115 116;; for (long unsigned i = 0; i < 5; i++) { 117;; A[2*i] = i; 118;; *B++ = A[10]; 119 120define void @weakzerodst2(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp { 121entry: 122 br label %for.body 123 124; CHECK: da analyze - none! 125; CHECK: da analyze - none! 126; CHECK: da analyze - confused! 127; CHECK: da analyze - consistent input [S]! 128; CHECK: da analyze - confused! 129; CHECK: da analyze - none! 130 131for.body: ; preds = %entry, %for.body 132 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ] 133 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ] 134 %conv = trunc i64 %i.02 to i32 135 %mul = shl i64 %i.02, 1 136 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %mul 137 store i32 %conv, i32* %arrayidx, align 4 138 %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 10 139 %0 = load i32, i32* %arrayidx1, align 4 140 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1 141 store i32 %0, i32* %B.addr.01, align 4 142 %inc = add i64 %i.02, 1 143 %exitcond = icmp ne i64 %inc, 5 144 br i1 %exitcond, label %for.body, label %for.end 145 146for.end: ; preds = %for.body 147 ret void 148} 149 150 151;; for (long unsigned i = 0; i < 6; i++) { 152;; A[2*i] = i; 153;; *B++ = A[10]; 154 155define void @weakzerodst3(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp { 156entry: 157 br label %for.body 158 159; CHECK: da analyze - none! 160; CHECK: da analyze - flow [=>p|<]! 161; CHECK: da analyze - confused! 162; CHECK: da analyze - consistent input [S]! 163; CHECK: da analyze - confused! 164; CHECK: da analyze - none! 165 166for.body: ; preds = %entry, %for.body 167 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ] 168 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ] 169 %conv = trunc i64 %i.02 to i32 170 %mul = shl i64 %i.02, 1 171 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %mul 172 store i32 %conv, i32* %arrayidx, align 4 173 %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 10 174 %0 = load i32, i32* %arrayidx1, align 4 175 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1 176 store i32 %0, i32* %B.addr.01, align 4 177 %inc = add i64 %i.02, 1 178 %exitcond = icmp ne i64 %inc, 6 179 br i1 %exitcond, label %for.body, label %for.end 180 181for.end: ; preds = %for.body 182 ret void 183} 184 185 186;; for (long unsigned i = 0; i < 7; i++) { 187;; A[2*i] = i; 188;; *B++ = A[10]; 189 190define void @weakzerodst4(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp { 191entry: 192 br label %for.body 193 194; CHECK: da analyze - none! 195; CHECK: da analyze - flow [*|<]! 196; CHECK: da analyze - confused! 197; CHECK: da analyze - consistent input [S]! 198; CHECK: da analyze - confused! 199; CHECK: da analyze - none! 200 201for.body: ; preds = %entry, %for.body 202 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ] 203 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ] 204 %conv = trunc i64 %i.02 to i32 205 %mul = shl i64 %i.02, 1 206 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %mul 207 store i32 %conv, i32* %arrayidx, align 4 208 %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 10 209 %0 = load i32, i32* %arrayidx1, align 4 210 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1 211 store i32 %0, i32* %B.addr.01, align 4 212 %inc = add i64 %i.02, 1 213 %exitcond = icmp ne i64 %inc, 7 214 br i1 %exitcond, label %for.body, label %for.end 215 216for.end: ; preds = %for.body 217 ret void 218} 219 220 221;; for (long unsigned i = 0; i < 7; i++) { 222;; A[2*i] = i; 223;; *B++ = A[-10]; 224 225define void @weakzerodst5(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp { 226entry: 227 br label %for.body 228 229; CHECK: da analyze - none! 230; CHECK: da analyze - none! 231; CHECK: da analyze - confused! 232; CHECK: da analyze - consistent input [S]! 233; CHECK: da analyze - confused! 234; CHECK: da analyze - none! 235 236for.body: ; preds = %entry, %for.body 237 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ] 238 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ] 239 %conv = trunc i64 %i.02 to i32 240 %mul = shl i64 %i.02, 1 241 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %mul 242 store i32 %conv, i32* %arrayidx, align 4 243 %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 -10 244 %0 = load i32, i32* %arrayidx1, align 4 245 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1 246 store i32 %0, i32* %B.addr.01, align 4 247 %inc = add i64 %i.02, 1 248 %exitcond = icmp ne i64 %inc, 7 249 br i1 %exitcond, label %for.body, label %for.end 250 251for.end: ; preds = %for.body 252 ret void 253} 254 255 256;; for (long unsigned i = 0; i < n; i++) { 257;; A[3*i] = i; 258;; *B++ = A[10]; 259 260define void @weakzerodst6(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp { 261entry: 262 %cmp1 = icmp eq i64 %n, 0 263 br i1 %cmp1, label %for.end, label %for.body.preheader 264 265; CHECK: da analyze - none! 266; CHECK: da analyze - none! 267; CHECK: da analyze - confused! 268; CHECK: da analyze - consistent input [S]! 269; CHECK: da analyze - confused! 270; CHECK: da analyze - none! 271 272for.body.preheader: ; preds = %entry 273 br label %for.body 274 275for.body: ; preds = %for.body.preheader, %for.body 276 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ] 277 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ] 278 %conv = trunc i64 %i.03 to i32 279 %mul = mul i64 %i.03, 3 280 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %mul 281 store i32 %conv, i32* %arrayidx, align 4 282 %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 10 283 %0 = load i32, i32* %arrayidx1, align 4 284 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1 285 store i32 %0, i32* %B.addr.02, align 4 286 %inc = add i64 %i.03, 1 287 %exitcond = icmp ne i64 %inc, %n 288 br i1 %exitcond, label %for.body, label %for.end.loopexit 289 290for.end.loopexit: ; preds = %for.body 291 br label %for.end 292 293for.end: ; preds = %for.end.loopexit, %entry 294 ret void 295} 296