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