1*cee313d2SEric Christopher; RUN: opt < %s -O1 -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -S | FileCheck %s 2*cee313d2SEric Christopher 3*cee313d2SEric Christophertarget datalayout = "e-p:32:32:32-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:64:128-a0:0:64-n32-S64" 4*cee313d2SEric Christopher 5*cee313d2SEric Christopher%struct.anon = type { [100 x i32], i32, [100 x i32] } 6*cee313d2SEric Christopher%struct.anon.0 = type { [100 x [100 x i32]], i32, [100 x [100 x i32]] } 7*cee313d2SEric Christopher 8*cee313d2SEric Christopher@Foo = common global %struct.anon zeroinitializer, align 4 9*cee313d2SEric Christopher@Bar = common global %struct.anon.0 zeroinitializer, align 4 10*cee313d2SEric Christopher 11*cee313d2SEric Christopher@PB = external global i32* 12*cee313d2SEric Christopher@PA = external global i32* 13*cee313d2SEric Christopher 14*cee313d2SEric Christopher 15*cee313d2SEric Christopher;; === First, the tests that should always vectorize, whether statically or by adding run-time checks === 16*cee313d2SEric Christopher 17*cee313d2SEric Christopher 18*cee313d2SEric Christopher; /// Different objects, positive induction, constant distance 19*cee313d2SEric Christopher; int noAlias01 (int a) { 20*cee313d2SEric Christopher; int i; 21*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 22*cee313d2SEric Christopher; Foo.A[i] = Foo.B[i] + a; 23*cee313d2SEric Christopher; return Foo.A[a]; 24*cee313d2SEric Christopher; } 25*cee313d2SEric Christopher; CHECK-LABEL: define i32 @noAlias01( 26*cee313d2SEric Christopher; CHECK: add nsw <4 x i32> 27*cee313d2SEric Christopher; CHECK: ret 28*cee313d2SEric Christopher 29*cee313d2SEric Christopherdefine i32 @noAlias01(i32 %a) nounwind { 30*cee313d2SEric Christopherentry: 31*cee313d2SEric Christopher %a.addr = alloca i32, align 4 32*cee313d2SEric Christopher %i = alloca i32, align 4 33*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 34*cee313d2SEric Christopher store i32 0, i32* %i, align 4 35*cee313d2SEric Christopher br label %for.cond 36*cee313d2SEric Christopher 37*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 38*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 39*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 40*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 41*cee313d2SEric Christopher 42*cee313d2SEric Christopherfor.body: ; preds = %for.cond 43*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 44*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %1 45*cee313d2SEric Christopher %2 = load i32, i32* %arrayidx, align 4 46*cee313d2SEric Christopher %3 = load i32, i32* %a.addr, align 4 47*cee313d2SEric Christopher %add = add nsw i32 %2, %3 48*cee313d2SEric Christopher %4 = load i32, i32* %i, align 4 49*cee313d2SEric Christopher %arrayidx1 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %4 50*cee313d2SEric Christopher store i32 %add, i32* %arrayidx1, align 4 51*cee313d2SEric Christopher br label %for.inc 52*cee313d2SEric Christopher 53*cee313d2SEric Christopherfor.inc: ; preds = %for.body 54*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 55*cee313d2SEric Christopher %inc = add nsw i32 %5, 1 56*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 57*cee313d2SEric Christopher br label %for.cond 58*cee313d2SEric Christopher 59*cee313d2SEric Christopherfor.end: ; preds = %for.cond 60*cee313d2SEric Christopher %6 = load i32, i32* %a.addr, align 4 61*cee313d2SEric Christopher %arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6 62*cee313d2SEric Christopher %7 = load i32, i32* %arrayidx2, align 4 63*cee313d2SEric Christopher ret i32 %7 64*cee313d2SEric Christopher} 65*cee313d2SEric Christopher 66*cee313d2SEric Christopher; /// Different objects, positive induction with widening slide 67*cee313d2SEric Christopher; int noAlias02 (int a) { 68*cee313d2SEric Christopher; int i; 69*cee313d2SEric Christopher; for (i=0; i<SIZE-10; i++) 70*cee313d2SEric Christopher; Foo.A[i] = Foo.B[i+10] + a; 71*cee313d2SEric Christopher; return Foo.A[a]; 72*cee313d2SEric Christopher; } 73*cee313d2SEric Christopher; CHECK-LABEL: define i32 @noAlias02( 74*cee313d2SEric Christopher; CHECK: add nsw <4 x i32> 75*cee313d2SEric Christopher; CHECK: ret 76*cee313d2SEric Christopher 77*cee313d2SEric Christopherdefine i32 @noAlias02(i32 %a) { 78*cee313d2SEric Christopherentry: 79*cee313d2SEric Christopher %a.addr = alloca i32, align 4 80*cee313d2SEric Christopher %i = alloca i32, align 4 81*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 82*cee313d2SEric Christopher store i32 0, i32* %i, align 4 83*cee313d2SEric Christopher br label %for.cond 84*cee313d2SEric Christopher 85*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 86*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 87*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 90 88*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 89*cee313d2SEric Christopher 90*cee313d2SEric Christopherfor.body: ; preds = %for.cond 91*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 92*cee313d2SEric Christopher %add = add nsw i32 %1, 10 93*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %add 94*cee313d2SEric Christopher %2 = load i32, i32* %arrayidx, align 4 95*cee313d2SEric Christopher %3 = load i32, i32* %a.addr, align 4 96*cee313d2SEric Christopher %add1 = add nsw i32 %2, %3 97*cee313d2SEric Christopher %4 = load i32, i32* %i, align 4 98*cee313d2SEric Christopher %arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %4 99*cee313d2SEric Christopher store i32 %add1, i32* %arrayidx2, align 4 100*cee313d2SEric Christopher br label %for.inc 101*cee313d2SEric Christopher 102*cee313d2SEric Christopherfor.inc: ; preds = %for.body 103*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 104*cee313d2SEric Christopher %inc = add nsw i32 %5, 1 105*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 106*cee313d2SEric Christopher br label %for.cond 107*cee313d2SEric Christopher 108*cee313d2SEric Christopherfor.end: ; preds = %for.cond 109*cee313d2SEric Christopher %6 = load i32, i32* %a.addr, align 4 110*cee313d2SEric Christopher %arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6 111*cee313d2SEric Christopher %7 = load i32, i32* %arrayidx3, align 4 112*cee313d2SEric Christopher ret i32 %7 113*cee313d2SEric Christopher} 114*cee313d2SEric Christopher 115*cee313d2SEric Christopher; /// Different objects, positive induction with shortening slide 116*cee313d2SEric Christopher; int noAlias03 (int a) { 117*cee313d2SEric Christopher; int i; 118*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 119*cee313d2SEric Christopher; Foo.A[i+10] = Foo.B[i] + a; 120*cee313d2SEric Christopher; return Foo.A[a]; 121*cee313d2SEric Christopher; } 122*cee313d2SEric Christopher; CHECK-LABEL: define i32 @noAlias03( 123*cee313d2SEric Christopher; CHECK: add nsw <4 x i32> 124*cee313d2SEric Christopher; CHECK: ret 125*cee313d2SEric Christopher 126*cee313d2SEric Christopherdefine i32 @noAlias03(i32 %a) { 127*cee313d2SEric Christopherentry: 128*cee313d2SEric Christopher %a.addr = alloca i32, align 4 129*cee313d2SEric Christopher %i = alloca i32, align 4 130*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 131*cee313d2SEric Christopher store i32 0, i32* %i, align 4 132*cee313d2SEric Christopher br label %for.cond 133*cee313d2SEric Christopher 134*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 135*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 136*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 137*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 138*cee313d2SEric Christopher 139*cee313d2SEric Christopherfor.body: ; preds = %for.cond 140*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 141*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %1 142*cee313d2SEric Christopher %2 = load i32, i32* %arrayidx, align 4 143*cee313d2SEric Christopher %3 = load i32, i32* %a.addr, align 4 144*cee313d2SEric Christopher %add = add nsw i32 %2, %3 145*cee313d2SEric Christopher %4 = load i32, i32* %i, align 4 146*cee313d2SEric Christopher %add1 = add nsw i32 %4, 10 147*cee313d2SEric Christopher %arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %add1 148*cee313d2SEric Christopher store i32 %add, i32* %arrayidx2, align 4 149*cee313d2SEric Christopher br label %for.inc 150*cee313d2SEric Christopher 151*cee313d2SEric Christopherfor.inc: ; preds = %for.body 152*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 153*cee313d2SEric Christopher %inc = add nsw i32 %5, 1 154*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 155*cee313d2SEric Christopher br label %for.cond 156*cee313d2SEric Christopher 157*cee313d2SEric Christopherfor.end: ; preds = %for.cond 158*cee313d2SEric Christopher %6 = load i32, i32* %a.addr, align 4 159*cee313d2SEric Christopher %arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6 160*cee313d2SEric Christopher %7 = load i32, i32* %arrayidx3, align 4 161*cee313d2SEric Christopher ret i32 %7 162*cee313d2SEric Christopher} 163*cee313d2SEric Christopher 164*cee313d2SEric Christopher; /// Pointer access, positive stride, run-time check added 165*cee313d2SEric Christopher; int noAlias04 (int a) { 166*cee313d2SEric Christopher; int i; 167*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 168*cee313d2SEric Christopher; *(PA+i) = *(PB+i) + a; 169*cee313d2SEric Christopher; return *(PA+a); 170*cee313d2SEric Christopher; } 171*cee313d2SEric Christopher; CHECK-LABEL: define i32 @noAlias04( 172*cee313d2SEric Christopher; CHECK-NOT: add nsw <4 x i32> 173*cee313d2SEric Christopher; CHECK: ret 174*cee313d2SEric Christopher; 175*cee313d2SEric Christopher; TODO: This test vectorizes (with run-time check) on real targets with -O3) 176*cee313d2SEric Christopher; Check why it's not being vectorized even when forcing vectorization 177*cee313d2SEric Christopher 178*cee313d2SEric Christopherdefine i32 @noAlias04(i32 %a) #0 { 179*cee313d2SEric Christopherentry: 180*cee313d2SEric Christopher %a.addr = alloca i32, align 4 181*cee313d2SEric Christopher %i = alloca i32, align 4 182*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 183*cee313d2SEric Christopher store i32 0, i32* %i, align 4 184*cee313d2SEric Christopher br label %for.cond 185*cee313d2SEric Christopher 186*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 187*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 188*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 189*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 190*cee313d2SEric Christopher 191*cee313d2SEric Christopherfor.body: ; preds = %for.cond 192*cee313d2SEric Christopher %1 = load i32*, i32** @PB, align 4 193*cee313d2SEric Christopher %2 = load i32, i32* %i, align 4 194*cee313d2SEric Christopher %add.ptr = getelementptr inbounds i32, i32* %1, i32 %2 195*cee313d2SEric Christopher %3 = load i32, i32* %add.ptr, align 4 196*cee313d2SEric Christopher %4 = load i32, i32* %a.addr, align 4 197*cee313d2SEric Christopher %add = add nsw i32 %3, %4 198*cee313d2SEric Christopher %5 = load i32*, i32** @PA, align 4 199*cee313d2SEric Christopher %6 = load i32, i32* %i, align 4 200*cee313d2SEric Christopher %add.ptr1 = getelementptr inbounds i32, i32* %5, i32 %6 201*cee313d2SEric Christopher store i32 %add, i32* %add.ptr1, align 4 202*cee313d2SEric Christopher br label %for.inc 203*cee313d2SEric Christopher 204*cee313d2SEric Christopherfor.inc: ; preds = %for.body 205*cee313d2SEric Christopher %7 = load i32, i32* %i, align 4 206*cee313d2SEric Christopher %inc = add nsw i32 %7, 1 207*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 208*cee313d2SEric Christopher br label %for.cond 209*cee313d2SEric Christopher 210*cee313d2SEric Christopherfor.end: ; preds = %for.cond 211*cee313d2SEric Christopher %8 = load i32*, i32** @PA, align 4 212*cee313d2SEric Christopher %9 = load i32, i32* %a.addr, align 4 213*cee313d2SEric Christopher %add.ptr2 = getelementptr inbounds i32, i32* %8, i32 %9 214*cee313d2SEric Christopher %10 = load i32, i32* %add.ptr2, align 4 215*cee313d2SEric Christopher ret i32 %10 216*cee313d2SEric Christopher} 217*cee313d2SEric Christopher 218*cee313d2SEric Christopher; /// Different objects, positive induction, multi-array 219*cee313d2SEric Christopher; int noAlias05 (int a) { 220*cee313d2SEric Christopher; int i, N=10; 221*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 222*cee313d2SEric Christopher; Bar.A[N][i] = Bar.B[N][i] + a; 223*cee313d2SEric Christopher; return Bar.A[N][a]; 224*cee313d2SEric Christopher; } 225*cee313d2SEric Christopher; CHECK-LABEL: define i32 @noAlias05( 226*cee313d2SEric Christopher; CHECK: add nsw <4 x i32> 227*cee313d2SEric Christopher; CHECK: ret 228*cee313d2SEric Christopher 229*cee313d2SEric Christopherdefine i32 @noAlias05(i32 %a) #0 { 230*cee313d2SEric Christopherentry: 231*cee313d2SEric Christopher %a.addr = alloca i32, align 4 232*cee313d2SEric Christopher %i = alloca i32, align 4 233*cee313d2SEric Christopher %N = alloca i32, align 4 234*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 235*cee313d2SEric Christopher store i32 10, i32* %N, align 4 236*cee313d2SEric Christopher store i32 0, i32* %i, align 4 237*cee313d2SEric Christopher br label %for.cond 238*cee313d2SEric Christopher 239*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 240*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 241*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 242*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 243*cee313d2SEric Christopher 244*cee313d2SEric Christopherfor.body: ; preds = %for.cond 245*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 246*cee313d2SEric Christopher %2 = load i32, i32* %N, align 4 247*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 2), i32 0, i32 %2 248*cee313d2SEric Christopher %arrayidx1 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx, i32 0, i32 %1 249*cee313d2SEric Christopher %3 = load i32, i32* %arrayidx1, align 4 250*cee313d2SEric Christopher %4 = load i32, i32* %a.addr, align 4 251*cee313d2SEric Christopher %add = add nsw i32 %3, %4 252*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 253*cee313d2SEric Christopher %6 = load i32, i32* %N, align 4 254*cee313d2SEric Christopher %arrayidx2 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %6 255*cee313d2SEric Christopher %arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx2, i32 0, i32 %5 256*cee313d2SEric Christopher store i32 %add, i32* %arrayidx3, align 4 257*cee313d2SEric Christopher br label %for.inc 258*cee313d2SEric Christopher 259*cee313d2SEric Christopherfor.inc: ; preds = %for.body 260*cee313d2SEric Christopher %7 = load i32, i32* %i, align 4 261*cee313d2SEric Christopher %inc = add nsw i32 %7, 1 262*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 263*cee313d2SEric Christopher br label %for.cond 264*cee313d2SEric Christopher 265*cee313d2SEric Christopherfor.end: ; preds = %for.cond 266*cee313d2SEric Christopher %8 = load i32, i32* %a.addr, align 4 267*cee313d2SEric Christopher %9 = load i32, i32* %N, align 4 268*cee313d2SEric Christopher %arrayidx4 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %9 269*cee313d2SEric Christopher %arrayidx5 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx4, i32 0, i32 %8 270*cee313d2SEric Christopher %10 = load i32, i32* %arrayidx5, align 4 271*cee313d2SEric Christopher ret i32 %10 272*cee313d2SEric Christopher} 273*cee313d2SEric Christopher 274*cee313d2SEric Christopher; /// Same objects, positive induction, multi-array, different sub-elements 275*cee313d2SEric Christopher; int noAlias06 (int a) { 276*cee313d2SEric Christopher; int i, N=10; 277*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 278*cee313d2SEric Christopher; Bar.A[N][i] = Bar.A[N+1][i] + a; 279*cee313d2SEric Christopher; return Bar.A[N][a]; 280*cee313d2SEric Christopher; } 281*cee313d2SEric Christopher; CHECK-LABEL: define i32 @noAlias06( 282*cee313d2SEric Christopher; CHECK: add nsw <4 x i32> 283*cee313d2SEric Christopher; CHECK: ret 284*cee313d2SEric Christopher 285*cee313d2SEric Christopherdefine i32 @noAlias06(i32 %a) #0 { 286*cee313d2SEric Christopherentry: 287*cee313d2SEric Christopher %a.addr = alloca i32, align 4 288*cee313d2SEric Christopher %i = alloca i32, align 4 289*cee313d2SEric Christopher %N = alloca i32, align 4 290*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 291*cee313d2SEric Christopher store i32 10, i32* %N, align 4 292*cee313d2SEric Christopher store i32 0, i32* %i, align 4 293*cee313d2SEric Christopher br label %for.cond 294*cee313d2SEric Christopher 295*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 296*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 297*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 298*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 299*cee313d2SEric Christopher 300*cee313d2SEric Christopherfor.body: ; preds = %for.cond 301*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 302*cee313d2SEric Christopher %2 = load i32, i32* %N, align 4 303*cee313d2SEric Christopher %add = add nsw i32 %2, 1 304*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %add 305*cee313d2SEric Christopher %arrayidx1 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx, i32 0, i32 %1 306*cee313d2SEric Christopher %3 = load i32, i32* %arrayidx1, align 4 307*cee313d2SEric Christopher %4 = load i32, i32* %a.addr, align 4 308*cee313d2SEric Christopher %add2 = add nsw i32 %3, %4 309*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 310*cee313d2SEric Christopher %6 = load i32, i32* %N, align 4 311*cee313d2SEric Christopher %arrayidx3 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %6 312*cee313d2SEric Christopher %arrayidx4 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx3, i32 0, i32 %5 313*cee313d2SEric Christopher store i32 %add2, i32* %arrayidx4, align 4 314*cee313d2SEric Christopher br label %for.inc 315*cee313d2SEric Christopher 316*cee313d2SEric Christopherfor.inc: ; preds = %for.body 317*cee313d2SEric Christopher %7 = load i32, i32* %i, align 4 318*cee313d2SEric Christopher %inc = add nsw i32 %7, 1 319*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 320*cee313d2SEric Christopher br label %for.cond 321*cee313d2SEric Christopher 322*cee313d2SEric Christopherfor.end: ; preds = %for.cond 323*cee313d2SEric Christopher %8 = load i32, i32* %a.addr, align 4 324*cee313d2SEric Christopher %9 = load i32, i32* %N, align 4 325*cee313d2SEric Christopher %arrayidx5 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %9 326*cee313d2SEric Christopher %arrayidx6 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx5, i32 0, i32 %8 327*cee313d2SEric Christopher %10 = load i32, i32* %arrayidx6, align 4 328*cee313d2SEric Christopher ret i32 %10 329*cee313d2SEric Christopher} 330*cee313d2SEric Christopher 331*cee313d2SEric Christopher; /// Different objects, negative induction, constant distance 332*cee313d2SEric Christopher; int noAlias07 (int a) { 333*cee313d2SEric Christopher; int i; 334*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 335*cee313d2SEric Christopher; Foo.A[SIZE-i-1] = Foo.B[SIZE-i-1] + a; 336*cee313d2SEric Christopher; return Foo.A[a]; 337*cee313d2SEric Christopher; } 338*cee313d2SEric Christopher; CHECK-LABEL: define i32 @noAlias07( 339*cee313d2SEric Christopher; CHECK: store <4 x i32> 340*cee313d2SEric Christopher; CHECK: ret 341*cee313d2SEric Christopherdefine i32 @noAlias07(i32 %a) #0 { 342*cee313d2SEric Christopherentry: 343*cee313d2SEric Christopher %a.addr = alloca i32, align 4 344*cee313d2SEric Christopher %i = alloca i32, align 4 345*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 346*cee313d2SEric Christopher store i32 0, i32* %i, align 4 347*cee313d2SEric Christopher br label %for.cond 348*cee313d2SEric Christopher 349*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 350*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 351*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 352*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 353*cee313d2SEric Christopher 354*cee313d2SEric Christopherfor.body: ; preds = %for.cond 355*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 356*cee313d2SEric Christopher %sub = sub nsw i32 100, %1 357*cee313d2SEric Christopher %sub1 = sub nsw i32 %sub, 1 358*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %sub1 359*cee313d2SEric Christopher %2 = load i32, i32* %arrayidx, align 4 360*cee313d2SEric Christopher %3 = load i32, i32* %a.addr, align 4 361*cee313d2SEric Christopher %add = add nsw i32 %2, %3 362*cee313d2SEric Christopher %4 = load i32, i32* %i, align 4 363*cee313d2SEric Christopher %sub2 = sub nsw i32 100, %4 364*cee313d2SEric Christopher %sub3 = sub nsw i32 %sub2, 1 365*cee313d2SEric Christopher %arrayidx4 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %sub3 366*cee313d2SEric Christopher store i32 %add, i32* %arrayidx4, align 4 367*cee313d2SEric Christopher br label %for.inc 368*cee313d2SEric Christopher 369*cee313d2SEric Christopherfor.inc: ; preds = %for.body 370*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 371*cee313d2SEric Christopher %inc = add nsw i32 %5, 1 372*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 373*cee313d2SEric Christopher br label %for.cond 374*cee313d2SEric Christopher 375*cee313d2SEric Christopherfor.end: ; preds = %for.cond 376*cee313d2SEric Christopher %6 = load i32, i32* %a.addr, align 4 377*cee313d2SEric Christopher %arrayidx5 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6 378*cee313d2SEric Christopher %7 = load i32, i32* %arrayidx5, align 4 379*cee313d2SEric Christopher ret i32 %7 380*cee313d2SEric Christopher} 381*cee313d2SEric Christopher 382*cee313d2SEric Christopher; /// Different objects, negative induction, shortening slide 383*cee313d2SEric Christopher; int noAlias08 (int a) { 384*cee313d2SEric Christopher; int i; 385*cee313d2SEric Christopher; for (i=0; i<SIZE-10; i++) 386*cee313d2SEric Christopher; Foo.A[SIZE-i-1] = Foo.B[SIZE-i-10] + a; 387*cee313d2SEric Christopher; return Foo.A[a]; 388*cee313d2SEric Christopher; } 389*cee313d2SEric Christopher; CHECK-LABEL: define i32 @noAlias08( 390*cee313d2SEric Christopher; CHECK: load <4 x i32> 391*cee313d2SEric Christopher; CHECK: ret 392*cee313d2SEric Christopher 393*cee313d2SEric Christopherdefine i32 @noAlias08(i32 %a) #0 { 394*cee313d2SEric Christopherentry: 395*cee313d2SEric Christopher %a.addr = alloca i32, align 4 396*cee313d2SEric Christopher %i = alloca i32, align 4 397*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 398*cee313d2SEric Christopher store i32 0, i32* %i, align 4 399*cee313d2SEric Christopher br label %for.cond 400*cee313d2SEric Christopher 401*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 402*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 403*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 90 404*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 405*cee313d2SEric Christopher 406*cee313d2SEric Christopherfor.body: ; preds = %for.cond 407*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 408*cee313d2SEric Christopher %sub = sub nsw i32 100, %1 409*cee313d2SEric Christopher %sub1 = sub nsw i32 %sub, 10 410*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %sub1 411*cee313d2SEric Christopher %2 = load i32, i32* %arrayidx, align 4 412*cee313d2SEric Christopher %3 = load i32, i32* %a.addr, align 4 413*cee313d2SEric Christopher %add = add nsw i32 %2, %3 414*cee313d2SEric Christopher %4 = load i32, i32* %i, align 4 415*cee313d2SEric Christopher %sub2 = sub nsw i32 100, %4 416*cee313d2SEric Christopher %sub3 = sub nsw i32 %sub2, 1 417*cee313d2SEric Christopher %arrayidx4 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %sub3 418*cee313d2SEric Christopher store i32 %add, i32* %arrayidx4, align 4 419*cee313d2SEric Christopher br label %for.inc 420*cee313d2SEric Christopher 421*cee313d2SEric Christopherfor.inc: ; preds = %for.body 422*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 423*cee313d2SEric Christopher %inc = add nsw i32 %5, 1 424*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 425*cee313d2SEric Christopher br label %for.cond 426*cee313d2SEric Christopher 427*cee313d2SEric Christopherfor.end: ; preds = %for.cond 428*cee313d2SEric Christopher %6 = load i32, i32* %a.addr, align 4 429*cee313d2SEric Christopher %arrayidx5 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6 430*cee313d2SEric Christopher %7 = load i32, i32* %arrayidx5, align 4 431*cee313d2SEric Christopher ret i32 %7 432*cee313d2SEric Christopher} 433*cee313d2SEric Christopher 434*cee313d2SEric Christopher; /// Different objects, negative induction, widening slide 435*cee313d2SEric Christopher; int noAlias09 (int a) { 436*cee313d2SEric Christopher; int i; 437*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 438*cee313d2SEric Christopher; Foo.A[SIZE-i-10] = Foo.B[SIZE-i-1] + a; 439*cee313d2SEric Christopher; return Foo.A[a]; 440*cee313d2SEric Christopher; } 441*cee313d2SEric Christopher; CHECK-LABEL: define i32 @noAlias09( 442*cee313d2SEric Christopher; CHECK: load <4 x i32> 443*cee313d2SEric Christopher; CHECK: ret 444*cee313d2SEric Christopher 445*cee313d2SEric Christopherdefine i32 @noAlias09(i32 %a) #0 { 446*cee313d2SEric Christopherentry: 447*cee313d2SEric Christopher %a.addr = alloca i32, align 4 448*cee313d2SEric Christopher %i = alloca i32, align 4 449*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 450*cee313d2SEric Christopher store i32 0, i32* %i, align 4 451*cee313d2SEric Christopher br label %for.cond 452*cee313d2SEric Christopher 453*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 454*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 455*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 456*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 457*cee313d2SEric Christopher 458*cee313d2SEric Christopherfor.body: ; preds = %for.cond 459*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 460*cee313d2SEric Christopher %sub = sub nsw i32 100, %1 461*cee313d2SEric Christopher %sub1 = sub nsw i32 %sub, 1 462*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %sub1 463*cee313d2SEric Christopher %2 = load i32, i32* %arrayidx, align 4 464*cee313d2SEric Christopher %3 = load i32, i32* %a.addr, align 4 465*cee313d2SEric Christopher %add = add nsw i32 %2, %3 466*cee313d2SEric Christopher %4 = load i32, i32* %i, align 4 467*cee313d2SEric Christopher %sub2 = sub nsw i32 100, %4 468*cee313d2SEric Christopher %sub3 = sub nsw i32 %sub2, 10 469*cee313d2SEric Christopher %arrayidx4 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %sub3 470*cee313d2SEric Christopher store i32 %add, i32* %arrayidx4, align 4 471*cee313d2SEric Christopher br label %for.inc 472*cee313d2SEric Christopher 473*cee313d2SEric Christopherfor.inc: ; preds = %for.body 474*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 475*cee313d2SEric Christopher %inc = add nsw i32 %5, 1 476*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 477*cee313d2SEric Christopher br label %for.cond 478*cee313d2SEric Christopher 479*cee313d2SEric Christopherfor.end: ; preds = %for.cond 480*cee313d2SEric Christopher %6 = load i32, i32* %a.addr, align 4 481*cee313d2SEric Christopher %arrayidx5 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6 482*cee313d2SEric Christopher %7 = load i32, i32* %arrayidx5, align 4 483*cee313d2SEric Christopher ret i32 %7 484*cee313d2SEric Christopher} 485*cee313d2SEric Christopher 486*cee313d2SEric Christopher; /// Pointer access, negative stride, run-time check added 487*cee313d2SEric Christopher; int noAlias10 (int a) { 488*cee313d2SEric Christopher; int i; 489*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 490*cee313d2SEric Christopher; *(PA+SIZE-i-1) = *(PB+SIZE-i-1) + a; 491*cee313d2SEric Christopher; return *(PA+a); 492*cee313d2SEric Christopher; } 493*cee313d2SEric Christopher; CHECK-LABEL: define i32 @noAlias10( 494*cee313d2SEric Christopher; CHECK-NOT: sub {{.*}} <4 x i32> 495*cee313d2SEric Christopher; CHECK: ret 496*cee313d2SEric Christopher; 497*cee313d2SEric Christopher; TODO: This test vectorizes (with run-time check) on real targets with -O3) 498*cee313d2SEric Christopher; Check why it's not being vectorized even when forcing vectorization 499*cee313d2SEric Christopher 500*cee313d2SEric Christopherdefine i32 @noAlias10(i32 %a) #0 { 501*cee313d2SEric Christopherentry: 502*cee313d2SEric Christopher %a.addr = alloca i32, align 4 503*cee313d2SEric Christopher %i = alloca i32, align 4 504*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 505*cee313d2SEric Christopher store i32 0, i32* %i, align 4 506*cee313d2SEric Christopher br label %for.cond 507*cee313d2SEric Christopher 508*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 509*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 510*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 511*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 512*cee313d2SEric Christopher 513*cee313d2SEric Christopherfor.body: ; preds = %for.cond 514*cee313d2SEric Christopher %1 = load i32*, i32** @PB, align 4 515*cee313d2SEric Christopher %add.ptr = getelementptr inbounds i32, i32* %1, i32 100 516*cee313d2SEric Christopher %2 = load i32, i32* %i, align 4 517*cee313d2SEric Christopher %idx.neg = sub i32 0, %2 518*cee313d2SEric Christopher %add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 %idx.neg 519*cee313d2SEric Christopher %add.ptr2 = getelementptr inbounds i32, i32* %add.ptr1, i32 -1 520*cee313d2SEric Christopher %3 = load i32, i32* %add.ptr2, align 4 521*cee313d2SEric Christopher %4 = load i32, i32* %a.addr, align 4 522*cee313d2SEric Christopher %add = add nsw i32 %3, %4 523*cee313d2SEric Christopher %5 = load i32*, i32** @PA, align 4 524*cee313d2SEric Christopher %add.ptr3 = getelementptr inbounds i32, i32* %5, i32 100 525*cee313d2SEric Christopher %6 = load i32, i32* %i, align 4 526*cee313d2SEric Christopher %idx.neg4 = sub i32 0, %6 527*cee313d2SEric Christopher %add.ptr5 = getelementptr inbounds i32, i32* %add.ptr3, i32 %idx.neg4 528*cee313d2SEric Christopher %add.ptr6 = getelementptr inbounds i32, i32* %add.ptr5, i32 -1 529*cee313d2SEric Christopher store i32 %add, i32* %add.ptr6, align 4 530*cee313d2SEric Christopher br label %for.inc 531*cee313d2SEric Christopher 532*cee313d2SEric Christopherfor.inc: ; preds = %for.body 533*cee313d2SEric Christopher %7 = load i32, i32* %i, align 4 534*cee313d2SEric Christopher %inc = add nsw i32 %7, 1 535*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 536*cee313d2SEric Christopher br label %for.cond 537*cee313d2SEric Christopher 538*cee313d2SEric Christopherfor.end: ; preds = %for.cond 539*cee313d2SEric Christopher %8 = load i32*, i32** @PA, align 4 540*cee313d2SEric Christopher %9 = load i32, i32* %a.addr, align 4 541*cee313d2SEric Christopher %add.ptr7 = getelementptr inbounds i32, i32* %8, i32 %9 542*cee313d2SEric Christopher %10 = load i32, i32* %add.ptr7, align 4 543*cee313d2SEric Christopher ret i32 %10 544*cee313d2SEric Christopher} 545*cee313d2SEric Christopher 546*cee313d2SEric Christopher; /// Different objects, negative induction, multi-array 547*cee313d2SEric Christopher; int noAlias11 (int a) { 548*cee313d2SEric Christopher; int i, N=10; 549*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 550*cee313d2SEric Christopher; Bar.A[N][SIZE-i-1] = Bar.B[N][SIZE-i-1] + a; 551*cee313d2SEric Christopher; return Bar.A[N][a]; 552*cee313d2SEric Christopher; } 553*cee313d2SEric Christopher; CHECK-LABEL: define i32 @noAlias11( 554*cee313d2SEric Christopher; CHECK: store <4 x i32> 555*cee313d2SEric Christopher; CHECK: ret 556*cee313d2SEric Christopher 557*cee313d2SEric Christopherdefine i32 @noAlias11(i32 %a) #0 { 558*cee313d2SEric Christopherentry: 559*cee313d2SEric Christopher %a.addr = alloca i32, align 4 560*cee313d2SEric Christopher %i = alloca i32, align 4 561*cee313d2SEric Christopher %N = alloca i32, align 4 562*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 563*cee313d2SEric Christopher store i32 10, i32* %N, align 4 564*cee313d2SEric Christopher store i32 0, i32* %i, align 4 565*cee313d2SEric Christopher br label %for.cond 566*cee313d2SEric Christopher 567*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 568*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 569*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 570*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 571*cee313d2SEric Christopher 572*cee313d2SEric Christopherfor.body: ; preds = %for.cond 573*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 574*cee313d2SEric Christopher %sub = sub nsw i32 100, %1 575*cee313d2SEric Christopher %sub1 = sub nsw i32 %sub, 1 576*cee313d2SEric Christopher %2 = load i32, i32* %N, align 4 577*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 2), i32 0, i32 %2 578*cee313d2SEric Christopher %arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx, i32 0, i32 %sub1 579*cee313d2SEric Christopher %3 = load i32, i32* %arrayidx2, align 4 580*cee313d2SEric Christopher %4 = load i32, i32* %a.addr, align 4 581*cee313d2SEric Christopher %add = add nsw i32 %3, %4 582*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 583*cee313d2SEric Christopher %sub3 = sub nsw i32 100, %5 584*cee313d2SEric Christopher %sub4 = sub nsw i32 %sub3, 1 585*cee313d2SEric Christopher %6 = load i32, i32* %N, align 4 586*cee313d2SEric Christopher %arrayidx5 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %6 587*cee313d2SEric Christopher %arrayidx6 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx5, i32 0, i32 %sub4 588*cee313d2SEric Christopher store i32 %add, i32* %arrayidx6, align 4 589*cee313d2SEric Christopher br label %for.inc 590*cee313d2SEric Christopher 591*cee313d2SEric Christopherfor.inc: ; preds = %for.body 592*cee313d2SEric Christopher %7 = load i32, i32* %i, align 4 593*cee313d2SEric Christopher %inc = add nsw i32 %7, 1 594*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 595*cee313d2SEric Christopher br label %for.cond 596*cee313d2SEric Christopher 597*cee313d2SEric Christopherfor.end: ; preds = %for.cond 598*cee313d2SEric Christopher %8 = load i32, i32* %a.addr, align 4 599*cee313d2SEric Christopher %9 = load i32, i32* %N, align 4 600*cee313d2SEric Christopher %arrayidx7 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %9 601*cee313d2SEric Christopher %arrayidx8 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx7, i32 0, i32 %8 602*cee313d2SEric Christopher %10 = load i32, i32* %arrayidx8, align 4 603*cee313d2SEric Christopher ret i32 %10 604*cee313d2SEric Christopher} 605*cee313d2SEric Christopher 606*cee313d2SEric Christopher; /// Same objects, negative induction, multi-array, different sub-elements 607*cee313d2SEric Christopher; int noAlias12 (int a) { 608*cee313d2SEric Christopher; int i, N=10; 609*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 610*cee313d2SEric Christopher; Bar.A[N][SIZE-i-1] = Bar.A[N+1][SIZE-i-1] + a; 611*cee313d2SEric Christopher; return Bar.A[N][a]; 612*cee313d2SEric Christopher; } 613*cee313d2SEric Christopher; CHECK-LABEL: define i32 @noAlias12( 614*cee313d2SEric Christopher; CHECK: store <4 x i32> 615*cee313d2SEric Christopher; CHECK: ret 616*cee313d2SEric Christopher 617*cee313d2SEric Christopherdefine i32 @noAlias12(i32 %a) #0 { 618*cee313d2SEric Christopherentry: 619*cee313d2SEric Christopher %a.addr = alloca i32, align 4 620*cee313d2SEric Christopher %i = alloca i32, align 4 621*cee313d2SEric Christopher %N = alloca i32, align 4 622*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 623*cee313d2SEric Christopher store i32 10, i32* %N, align 4 624*cee313d2SEric Christopher store i32 0, i32* %i, align 4 625*cee313d2SEric Christopher br label %for.cond 626*cee313d2SEric Christopher 627*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 628*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 629*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 630*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 631*cee313d2SEric Christopher 632*cee313d2SEric Christopherfor.body: ; preds = %for.cond 633*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 634*cee313d2SEric Christopher %sub = sub nsw i32 100, %1 635*cee313d2SEric Christopher %sub1 = sub nsw i32 %sub, 1 636*cee313d2SEric Christopher %2 = load i32, i32* %N, align 4 637*cee313d2SEric Christopher %add = add nsw i32 %2, 1 638*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %add 639*cee313d2SEric Christopher %arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx, i32 0, i32 %sub1 640*cee313d2SEric Christopher %3 = load i32, i32* %arrayidx2, align 4 641*cee313d2SEric Christopher %4 = load i32, i32* %a.addr, align 4 642*cee313d2SEric Christopher %add3 = add nsw i32 %3, %4 643*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 644*cee313d2SEric Christopher %sub4 = sub nsw i32 100, %5 645*cee313d2SEric Christopher %sub5 = sub nsw i32 %sub4, 1 646*cee313d2SEric Christopher %6 = load i32, i32* %N, align 4 647*cee313d2SEric Christopher %arrayidx6 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %6 648*cee313d2SEric Christopher %arrayidx7 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx6, i32 0, i32 %sub5 649*cee313d2SEric Christopher store i32 %add3, i32* %arrayidx7, align 4 650*cee313d2SEric Christopher br label %for.inc 651*cee313d2SEric Christopher 652*cee313d2SEric Christopherfor.inc: ; preds = %for.body 653*cee313d2SEric Christopher %7 = load i32, i32* %i, align 4 654*cee313d2SEric Christopher %inc = add nsw i32 %7, 1 655*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 656*cee313d2SEric Christopher br label %for.cond 657*cee313d2SEric Christopher 658*cee313d2SEric Christopherfor.end: ; preds = %for.cond 659*cee313d2SEric Christopher %8 = load i32, i32* %a.addr, align 4 660*cee313d2SEric Christopher %9 = load i32, i32* %N, align 4 661*cee313d2SEric Christopher %arrayidx8 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* getelementptr inbounds (%struct.anon.0, %struct.anon.0* @Bar, i32 0, i32 0), i32 0, i32 %9 662*cee313d2SEric Christopher %arrayidx9 = getelementptr inbounds [100 x i32], [100 x i32]* %arrayidx8, i32 0, i32 %8 663*cee313d2SEric Christopher %10 = load i32, i32* %arrayidx9, align 4 664*cee313d2SEric Christopher ret i32 %10 665*cee313d2SEric Christopher} 666*cee313d2SEric Christopher 667*cee313d2SEric Christopher; /// Same objects, positive induction, constant distance, just enough for vector size 668*cee313d2SEric Christopher; int noAlias13 (int a) { 669*cee313d2SEric Christopher; int i; 670*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 671*cee313d2SEric Christopher; Foo.A[i] = Foo.A[i+4] + a; 672*cee313d2SEric Christopher; return Foo.A[a]; 673*cee313d2SEric Christopher; } 674*cee313d2SEric Christopher; CHECK-LABEL: define i32 @noAlias13( 675*cee313d2SEric Christopher; CHECK: add nsw <4 x i32> 676*cee313d2SEric Christopher; CHECK: ret 677*cee313d2SEric Christopher 678*cee313d2SEric Christopherdefine i32 @noAlias13(i32 %a) #0 { 679*cee313d2SEric Christopherentry: 680*cee313d2SEric Christopher %a.addr = alloca i32, align 4 681*cee313d2SEric Christopher %i = alloca i32, align 4 682*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 683*cee313d2SEric Christopher store i32 0, i32* %i, align 4 684*cee313d2SEric Christopher br label %for.cond 685*cee313d2SEric Christopher 686*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 687*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 688*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 689*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 690*cee313d2SEric Christopher 691*cee313d2SEric Christopherfor.body: ; preds = %for.cond 692*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 693*cee313d2SEric Christopher %add = add nsw i32 %1, 4 694*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %add 695*cee313d2SEric Christopher %2 = load i32, i32* %arrayidx, align 4 696*cee313d2SEric Christopher %3 = load i32, i32* %a.addr, align 4 697*cee313d2SEric Christopher %add1 = add nsw i32 %2, %3 698*cee313d2SEric Christopher %4 = load i32, i32* %i, align 4 699*cee313d2SEric Christopher %arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %4 700*cee313d2SEric Christopher store i32 %add1, i32* %arrayidx2, align 4 701*cee313d2SEric Christopher br label %for.inc 702*cee313d2SEric Christopher 703*cee313d2SEric Christopherfor.inc: ; preds = %for.body 704*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 705*cee313d2SEric Christopher %inc = add nsw i32 %5, 1 706*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 707*cee313d2SEric Christopher br label %for.cond 708*cee313d2SEric Christopher 709*cee313d2SEric Christopherfor.end: ; preds = %for.cond 710*cee313d2SEric Christopher %6 = load i32, i32* %a.addr, align 4 711*cee313d2SEric Christopher %arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6 712*cee313d2SEric Christopher %7 = load i32, i32* %arrayidx3, align 4 713*cee313d2SEric Christopher ret i32 %7 714*cee313d2SEric Christopher} 715*cee313d2SEric Christopher 716*cee313d2SEric Christopher; /// Same objects, negative induction, constant distance, just enough for vector size 717*cee313d2SEric Christopher; int noAlias14 (int a) { 718*cee313d2SEric Christopher; int i; 719*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 720*cee313d2SEric Christopher; Foo.A[SIZE-i-1] = Foo.A[SIZE-i-5] + a; 721*cee313d2SEric Christopher; return Foo.A[a]; 722*cee313d2SEric Christopher; } 723*cee313d2SEric Christopher; CHECK-LABEL: define i32 @noAlias14( 724*cee313d2SEric Christopher; CHECK: load <4 x i32> 725*cee313d2SEric Christopher; CHECK: ret 726*cee313d2SEric Christopher 727*cee313d2SEric Christopherdefine i32 @noAlias14(i32 %a) #0 { 728*cee313d2SEric Christopherentry: 729*cee313d2SEric Christopher %a.addr = alloca i32, align 4 730*cee313d2SEric Christopher %i = alloca i32, align 4 731*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 732*cee313d2SEric Christopher store i32 0, i32* %i, align 4 733*cee313d2SEric Christopher br label %for.cond 734*cee313d2SEric Christopher 735*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 736*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 737*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 738*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 739*cee313d2SEric Christopher 740*cee313d2SEric Christopherfor.body: ; preds = %for.cond 741*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 742*cee313d2SEric Christopher %sub = sub nsw i32 100, %1 743*cee313d2SEric Christopher %sub1 = sub nsw i32 %sub, 5 744*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %sub1 745*cee313d2SEric Christopher %2 = load i32, i32* %arrayidx, align 4 746*cee313d2SEric Christopher %3 = load i32, i32* %a.addr, align 4 747*cee313d2SEric Christopher %add = add nsw i32 %2, %3 748*cee313d2SEric Christopher %4 = load i32, i32* %i, align 4 749*cee313d2SEric Christopher %sub2 = sub nsw i32 100, %4 750*cee313d2SEric Christopher %sub3 = sub nsw i32 %sub2, 1 751*cee313d2SEric Christopher %arrayidx4 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %sub3 752*cee313d2SEric Christopher store i32 %add, i32* %arrayidx4, align 4 753*cee313d2SEric Christopher br label %for.inc 754*cee313d2SEric Christopher 755*cee313d2SEric Christopherfor.inc: ; preds = %for.body 756*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 757*cee313d2SEric Christopher %inc = add nsw i32 %5, 1 758*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 759*cee313d2SEric Christopher br label %for.cond 760*cee313d2SEric Christopher 761*cee313d2SEric Christopherfor.end: ; preds = %for.cond 762*cee313d2SEric Christopher %6 = load i32, i32* %a.addr, align 4 763*cee313d2SEric Christopher %arrayidx5 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6 764*cee313d2SEric Christopher %7 = load i32, i32* %arrayidx5, align 4 765*cee313d2SEric Christopher ret i32 %7 766*cee313d2SEric Christopher} 767*cee313d2SEric Christopher 768*cee313d2SEric Christopher 769*cee313d2SEric Christopher;; === Now, the tests that we could vectorize with induction changes or run-time checks === 770*cee313d2SEric Christopher 771*cee313d2SEric Christopher 772*cee313d2SEric Christopher; /// Different objects, swapped induction, alias at the end 773*cee313d2SEric Christopher; int mayAlias01 (int a) { 774*cee313d2SEric Christopher; int i; 775*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 776*cee313d2SEric Christopher; Foo.A[i] = Foo.B[SIZE-i-1] + a; 777*cee313d2SEric Christopher; return Foo.A[a]; 778*cee313d2SEric Christopher; } 779*cee313d2SEric Christopher; CHECK-LABEL: define i32 @mayAlias01( 780*cee313d2SEric Christopher; CHECK-NOT: add nsw <4 x i32> 781*cee313d2SEric Christopher; CHECK: ret 782*cee313d2SEric Christopher 783*cee313d2SEric Christopherdefine i32 @mayAlias01(i32 %a) nounwind { 784*cee313d2SEric Christopherentry: 785*cee313d2SEric Christopher %a.addr = alloca i32, align 4 786*cee313d2SEric Christopher %i = alloca i32, align 4 787*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 788*cee313d2SEric Christopher store i32 0, i32* %i, align 4 789*cee313d2SEric Christopher br label %for.cond 790*cee313d2SEric Christopher 791*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 792*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 793*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 794*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 795*cee313d2SEric Christopher 796*cee313d2SEric Christopherfor.body: ; preds = %for.cond 797*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 798*cee313d2SEric Christopher %sub = sub nsw i32 100, %1 799*cee313d2SEric Christopher %sub1 = sub nsw i32 %sub, 1 800*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %sub1 801*cee313d2SEric Christopher %2 = load i32, i32* %arrayidx, align 4 802*cee313d2SEric Christopher %3 = load i32, i32* %a.addr, align 4 803*cee313d2SEric Christopher %add = add nsw i32 %2, %3 804*cee313d2SEric Christopher %4 = load i32, i32* %i, align 4 805*cee313d2SEric Christopher %arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %4 806*cee313d2SEric Christopher store i32 %add, i32* %arrayidx2, align 4 807*cee313d2SEric Christopher br label %for.inc 808*cee313d2SEric Christopher 809*cee313d2SEric Christopherfor.inc: ; preds = %for.body 810*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 811*cee313d2SEric Christopher %inc = add nsw i32 %5, 1 812*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 813*cee313d2SEric Christopher br label %for.cond 814*cee313d2SEric Christopher 815*cee313d2SEric Christopherfor.end: ; preds = %for.cond 816*cee313d2SEric Christopher %6 = load i32, i32* %a.addr, align 4 817*cee313d2SEric Christopher %arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6 818*cee313d2SEric Christopher %7 = load i32, i32* %arrayidx3, align 4 819*cee313d2SEric Christopher ret i32 %7 820*cee313d2SEric Christopher} 821*cee313d2SEric Christopher 822*cee313d2SEric Christopher; /// Different objects, swapped induction, alias at the beginning 823*cee313d2SEric Christopher; int mayAlias02 (int a) { 824*cee313d2SEric Christopher; int i; 825*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 826*cee313d2SEric Christopher; Foo.A[SIZE-i-1] = Foo.B[i] + a; 827*cee313d2SEric Christopher; return Foo.A[a]; 828*cee313d2SEric Christopher; } 829*cee313d2SEric Christopher; CHECK-LABEL: define i32 @mayAlias02( 830*cee313d2SEric Christopher; CHECK-NOT: add nsw <4 x i32> 831*cee313d2SEric Christopher; CHECK: ret 832*cee313d2SEric Christopher 833*cee313d2SEric Christopherdefine i32 @mayAlias02(i32 %a) nounwind { 834*cee313d2SEric Christopherentry: 835*cee313d2SEric Christopher %a.addr = alloca i32, align 4 836*cee313d2SEric Christopher %i = alloca i32, align 4 837*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 838*cee313d2SEric Christopher store i32 0, i32* %i, align 4 839*cee313d2SEric Christopher br label %for.cond 840*cee313d2SEric Christopher 841*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 842*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 843*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 844*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 845*cee313d2SEric Christopher 846*cee313d2SEric Christopherfor.body: ; preds = %for.cond 847*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 848*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %1 849*cee313d2SEric Christopher %2 = load i32, i32* %arrayidx, align 4 850*cee313d2SEric Christopher %3 = load i32, i32* %a.addr, align 4 851*cee313d2SEric Christopher %add = add nsw i32 %2, %3 852*cee313d2SEric Christopher %4 = load i32, i32* %i, align 4 853*cee313d2SEric Christopher %sub = sub nsw i32 100, %4 854*cee313d2SEric Christopher %sub1 = sub nsw i32 %sub, 1 855*cee313d2SEric Christopher %arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %sub1 856*cee313d2SEric Christopher store i32 %add, i32* %arrayidx2, align 4 857*cee313d2SEric Christopher br label %for.inc 858*cee313d2SEric Christopher 859*cee313d2SEric Christopherfor.inc: ; preds = %for.body 860*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 861*cee313d2SEric Christopher %inc = add nsw i32 %5, 1 862*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 863*cee313d2SEric Christopher br label %for.cond 864*cee313d2SEric Christopher 865*cee313d2SEric Christopherfor.end: ; preds = %for.cond 866*cee313d2SEric Christopher %6 = load i32, i32* %a.addr, align 4 867*cee313d2SEric Christopher %arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6 868*cee313d2SEric Christopher %7 = load i32, i32* %arrayidx3, align 4 869*cee313d2SEric Christopher ret i32 %7 870*cee313d2SEric Christopher} 871*cee313d2SEric Christopher 872*cee313d2SEric Christopher; /// Pointer access, run-time check added 873*cee313d2SEric Christopher; int mayAlias03 (int a) { 874*cee313d2SEric Christopher; int i; 875*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 876*cee313d2SEric Christopher; *(PA+i) = *(PB+SIZE-i-1) + a; 877*cee313d2SEric Christopher; return *(PA+a); 878*cee313d2SEric Christopher; } 879*cee313d2SEric Christopher; CHECK-LABEL: define i32 @mayAlias03( 880*cee313d2SEric Christopher; CHECK-NOT: add nsw <4 x i32> 881*cee313d2SEric Christopher; CHECK: ret 882*cee313d2SEric Christopher 883*cee313d2SEric Christopherdefine i32 @mayAlias03(i32 %a) nounwind { 884*cee313d2SEric Christopherentry: 885*cee313d2SEric Christopher %a.addr = alloca i32, align 4 886*cee313d2SEric Christopher %i = alloca i32, align 4 887*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 888*cee313d2SEric Christopher store i32 0, i32* %i, align 4 889*cee313d2SEric Christopher br label %for.cond 890*cee313d2SEric Christopher 891*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 892*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 893*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 894*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 895*cee313d2SEric Christopher 896*cee313d2SEric Christopherfor.body: ; preds = %for.cond 897*cee313d2SEric Christopher %1 = load i32*, i32** @PB, align 4 898*cee313d2SEric Christopher %add.ptr = getelementptr inbounds i32, i32* %1, i32 100 899*cee313d2SEric Christopher %2 = load i32, i32* %i, align 4 900*cee313d2SEric Christopher %idx.neg = sub i32 0, %2 901*cee313d2SEric Christopher %add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 %idx.neg 902*cee313d2SEric Christopher %add.ptr2 = getelementptr inbounds i32, i32* %add.ptr1, i32 -1 903*cee313d2SEric Christopher %3 = load i32, i32* %add.ptr2, align 4 904*cee313d2SEric Christopher %4 = load i32, i32* %a.addr, align 4 905*cee313d2SEric Christopher %add = add nsw i32 %3, %4 906*cee313d2SEric Christopher %5 = load i32*, i32** @PA, align 4 907*cee313d2SEric Christopher %6 = load i32, i32* %i, align 4 908*cee313d2SEric Christopher %add.ptr3 = getelementptr inbounds i32, i32* %5, i32 %6 909*cee313d2SEric Christopher store i32 %add, i32* %add.ptr3, align 4 910*cee313d2SEric Christopher br label %for.inc 911*cee313d2SEric Christopher 912*cee313d2SEric Christopherfor.inc: ; preds = %for.body 913*cee313d2SEric Christopher %7 = load i32, i32* %i, align 4 914*cee313d2SEric Christopher %inc = add nsw i32 %7, 1 915*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 916*cee313d2SEric Christopher br label %for.cond 917*cee313d2SEric Christopher 918*cee313d2SEric Christopherfor.end: ; preds = %for.cond 919*cee313d2SEric Christopher %8 = load i32*, i32** @PA, align 4 920*cee313d2SEric Christopher %9 = load i32, i32* %a.addr, align 4 921*cee313d2SEric Christopher %add.ptr4 = getelementptr inbounds i32, i32* %8, i32 %9 922*cee313d2SEric Christopher %10 = load i32, i32* %add.ptr4, align 4 923*cee313d2SEric Christopher ret i32 %10 924*cee313d2SEric Christopher} 925*cee313d2SEric Christopher 926*cee313d2SEric Christopher 927*cee313d2SEric Christopher;; === Finally, the tests that should only vectorize with care (or if we ignore undefined behaviour at all) === 928*cee313d2SEric Christopher 929*cee313d2SEric Christopher 930*cee313d2SEric Christopher; int mustAlias01 (int a) { 931*cee313d2SEric Christopher; int i; 932*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 933*cee313d2SEric Christopher; Foo.A[i+10] = Foo.B[SIZE-i-1] + a; 934*cee313d2SEric Christopher; return Foo.A[a]; 935*cee313d2SEric Christopher; } 936*cee313d2SEric Christopher; CHECK-LABEL: define i32 @mustAlias01( 937*cee313d2SEric Christopher; CHECK-NOT: add nsw <4 x i32> 938*cee313d2SEric Christopher; CHECK: ret 939*cee313d2SEric Christopher 940*cee313d2SEric Christopherdefine i32 @mustAlias01(i32 %a) nounwind { 941*cee313d2SEric Christopherentry: 942*cee313d2SEric Christopher %a.addr = alloca i32, align 4 943*cee313d2SEric Christopher %i = alloca i32, align 4 944*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 945*cee313d2SEric Christopher store i32 0, i32* %i, align 4 946*cee313d2SEric Christopher br label %for.cond 947*cee313d2SEric Christopher 948*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 949*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 950*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 951*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 952*cee313d2SEric Christopher 953*cee313d2SEric Christopherfor.body: ; preds = %for.cond 954*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 955*cee313d2SEric Christopher %sub = sub nsw i32 100, %1 956*cee313d2SEric Christopher %sub1 = sub nsw i32 %sub, 1 957*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %sub1 958*cee313d2SEric Christopher %2 = load i32, i32* %arrayidx, align 4 959*cee313d2SEric Christopher %3 = load i32, i32* %a.addr, align 4 960*cee313d2SEric Christopher %add = add nsw i32 %2, %3 961*cee313d2SEric Christopher %4 = load i32, i32* %i, align 4 962*cee313d2SEric Christopher %add2 = add nsw i32 %4, 10 963*cee313d2SEric Christopher %arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %add2 964*cee313d2SEric Christopher store i32 %add, i32* %arrayidx3, align 4 965*cee313d2SEric Christopher br label %for.inc 966*cee313d2SEric Christopher 967*cee313d2SEric Christopherfor.inc: ; preds = %for.body 968*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 969*cee313d2SEric Christopher %inc = add nsw i32 %5, 1 970*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 971*cee313d2SEric Christopher br label %for.cond 972*cee313d2SEric Christopher 973*cee313d2SEric Christopherfor.end: ; preds = %for.cond 974*cee313d2SEric Christopher %6 = load i32, i32* %a.addr, align 4 975*cee313d2SEric Christopher %arrayidx4 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6 976*cee313d2SEric Christopher %7 = load i32, i32* %arrayidx4, align 4 977*cee313d2SEric Christopher ret i32 %7 978*cee313d2SEric Christopher} 979*cee313d2SEric Christopher 980*cee313d2SEric Christopher; int mustAlias02 (int a) { 981*cee313d2SEric Christopher; int i; 982*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 983*cee313d2SEric Christopher; Foo.A[i] = Foo.B[SIZE-i-10] + a; 984*cee313d2SEric Christopher; return Foo.A[a]; 985*cee313d2SEric Christopher; } 986*cee313d2SEric Christopher; CHECK-LABEL: define i32 @mustAlias02( 987*cee313d2SEric Christopher; CHECK-NOT: add nsw <4 x i32> 988*cee313d2SEric Christopher; CHECK: ret 989*cee313d2SEric Christopher 990*cee313d2SEric Christopherdefine i32 @mustAlias02(i32 %a) nounwind { 991*cee313d2SEric Christopherentry: 992*cee313d2SEric Christopher %a.addr = alloca i32, align 4 993*cee313d2SEric Christopher %i = alloca i32, align 4 994*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 995*cee313d2SEric Christopher store i32 0, i32* %i, align 4 996*cee313d2SEric Christopher br label %for.cond 997*cee313d2SEric Christopher 998*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 999*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 1000*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 1001*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 1002*cee313d2SEric Christopher 1003*cee313d2SEric Christopherfor.body: ; preds = %for.cond 1004*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 1005*cee313d2SEric Christopher %sub = sub nsw i32 100, %1 1006*cee313d2SEric Christopher %sub1 = sub nsw i32 %sub, 10 1007*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %sub1 1008*cee313d2SEric Christopher %2 = load i32, i32* %arrayidx, align 4 1009*cee313d2SEric Christopher %3 = load i32, i32* %a.addr, align 4 1010*cee313d2SEric Christopher %add = add nsw i32 %2, %3 1011*cee313d2SEric Christopher %4 = load i32, i32* %i, align 4 1012*cee313d2SEric Christopher %arrayidx2 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %4 1013*cee313d2SEric Christopher store i32 %add, i32* %arrayidx2, align 4 1014*cee313d2SEric Christopher br label %for.inc 1015*cee313d2SEric Christopher 1016*cee313d2SEric Christopherfor.inc: ; preds = %for.body 1017*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 1018*cee313d2SEric Christopher %inc = add nsw i32 %5, 1 1019*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 1020*cee313d2SEric Christopher br label %for.cond 1021*cee313d2SEric Christopher 1022*cee313d2SEric Christopherfor.end: ; preds = %for.cond 1023*cee313d2SEric Christopher %6 = load i32, i32* %a.addr, align 4 1024*cee313d2SEric Christopher %arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6 1025*cee313d2SEric Christopher %7 = load i32, i32* %arrayidx3, align 4 1026*cee313d2SEric Christopher ret i32 %7 1027*cee313d2SEric Christopher} 1028*cee313d2SEric Christopher 1029*cee313d2SEric Christopher; int mustAlias03 (int a) { 1030*cee313d2SEric Christopher; int i; 1031*cee313d2SEric Christopher; for (i=0; i<SIZE; i++) 1032*cee313d2SEric Christopher; Foo.A[i+10] = Foo.B[SIZE-i-10] + a; 1033*cee313d2SEric Christopher; return Foo.A[a]; 1034*cee313d2SEric Christopher; } 1035*cee313d2SEric Christopher; CHECK-LABEL: define i32 @mustAlias03( 1036*cee313d2SEric Christopher; CHECK-NOT: add nsw <4 x i32> 1037*cee313d2SEric Christopher; CHECK: ret 1038*cee313d2SEric Christopher 1039*cee313d2SEric Christopherdefine i32 @mustAlias03(i32 %a) nounwind { 1040*cee313d2SEric Christopherentry: 1041*cee313d2SEric Christopher %a.addr = alloca i32, align 4 1042*cee313d2SEric Christopher %i = alloca i32, align 4 1043*cee313d2SEric Christopher store i32 %a, i32* %a.addr, align 4 1044*cee313d2SEric Christopher store i32 0, i32* %i, align 4 1045*cee313d2SEric Christopher br label %for.cond 1046*cee313d2SEric Christopher 1047*cee313d2SEric Christopherfor.cond: ; preds = %for.inc, %entry 1048*cee313d2SEric Christopher %0 = load i32, i32* %i, align 4 1049*cee313d2SEric Christopher %cmp = icmp slt i32 %0, 100 1050*cee313d2SEric Christopher br i1 %cmp, label %for.body, label %for.end 1051*cee313d2SEric Christopher 1052*cee313d2SEric Christopherfor.body: ; preds = %for.cond 1053*cee313d2SEric Christopher %1 = load i32, i32* %i, align 4 1054*cee313d2SEric Christopher %sub = sub nsw i32 100, %1 1055*cee313d2SEric Christopher %sub1 = sub nsw i32 %sub, 10 1056*cee313d2SEric Christopher %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 2), i32 0, i32 %sub1 1057*cee313d2SEric Christopher %2 = load i32, i32* %arrayidx, align 4 1058*cee313d2SEric Christopher %3 = load i32, i32* %a.addr, align 4 1059*cee313d2SEric Christopher %add = add nsw i32 %2, %3 1060*cee313d2SEric Christopher %4 = load i32, i32* %i, align 4 1061*cee313d2SEric Christopher %add2 = add nsw i32 %4, 10 1062*cee313d2SEric Christopher %arrayidx3 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %add2 1063*cee313d2SEric Christopher store i32 %add, i32* %arrayidx3, align 4 1064*cee313d2SEric Christopher br label %for.inc 1065*cee313d2SEric Christopher 1066*cee313d2SEric Christopherfor.inc: ; preds = %for.body 1067*cee313d2SEric Christopher %5 = load i32, i32* %i, align 4 1068*cee313d2SEric Christopher %inc = add nsw i32 %5, 1 1069*cee313d2SEric Christopher store i32 %inc, i32* %i, align 4 1070*cee313d2SEric Christopher br label %for.cond 1071*cee313d2SEric Christopher 1072*cee313d2SEric Christopherfor.end: ; preds = %for.cond 1073*cee313d2SEric Christopher %6 = load i32, i32* %a.addr, align 4 1074*cee313d2SEric Christopher %arrayidx4 = getelementptr inbounds [100 x i32], [100 x i32]* getelementptr inbounds (%struct.anon, %struct.anon* @Foo, i32 0, i32 0), i32 0, i32 %6 1075*cee313d2SEric Christopher %7 = load i32, i32* %arrayidx4, align 4 1076*cee313d2SEric Christopher ret i32 %7 1077*cee313d2SEric Christopher} 1078