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