1 ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output 2>&1 | FileCheck %s 2 target 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" 3 target triple = "x86_64-unknown-linux-gnu" 4 5 ; rdar://7282591 6 7 @X = common global i32 0 8 @Y = common global i32 0 9 @Z = common global i32 0 10 11 ; CHECK-LABEL: foo 12 ; CHECK: NoAlias: i32* %P, i32* @Z 13 14 define void @foo(i32 %cond) nounwind { 15 entry: 16 %"alloca point" = bitcast i32 0 to i32 17 %tmp = icmp ne i32 %cond, 0 18 br i1 %tmp, label %bb, label %bb1 19 20 bb: 21 br label %bb2 22 23 bb1: 24 br label %bb2 25 26 bb2: 27 %P = phi i32* [ @X, %bb ], [ @Y, %bb1 ] 28 %tmp1 = load i32* @Z, align 4 29 store i32 123, i32* %P, align 4 30 %tmp2 = load i32* @Z, align 4 31 br label %return 32 33 return: 34 ret void 35 } 36 37 ; Pointers can vary in between iterations of loops. 38 ; PR18068 39 40 ; CHECK-LABEL: pr18068 41 ; CHECK: MayAlias: i32* %0, i32* %arrayidx5 42 43 define i32 @pr18068(i32* %jj7, i32* %j) { 44 entry: 45 %oa5 = alloca [100 x i32], align 16 46 br label %codeRepl 47 48 codeRepl: 49 %0 = phi i32* [ %arrayidx13, %for.body ], [ %j, %entry ] 50 %targetBlock = call i1 @cond(i32* %jj7) 51 br i1 %targetBlock, label %for.body, label %bye 52 53 for.body: 54 %1 = load i32* %jj7, align 4 55 %idxprom4 = zext i32 %1 to i64 56 %arrayidx5 = getelementptr inbounds [100 x i32]* %oa5, i64 0, i64 %idxprom4 57 %2 = load i32* %arrayidx5, align 4 58 %sub6 = sub i32 %2, 6 59 store i32 %sub6, i32* %arrayidx5, align 4 60 ; %0 and %arrayidx5 can alias! It is not safe to DSE the above store. 61 %3 = load i32* %0, align 4 62 store i32 %3, i32* %arrayidx5, align 4 63 %sub11 = add i32 %1, -1 64 %idxprom12 = zext i32 %sub11 to i64 65 %arrayidx13 = getelementptr inbounds [100 x i32]* %oa5, i64 0, i64 %idxprom12 66 call void @inc(i32* %jj7) 67 br label %codeRepl 68 69 bye: 70 %.reload = load i32* %jj7, align 4 71 ret i32 %.reload 72 } 73 74 declare i1 @cond(i32*) 75 76 declare void @inc(i32*) 77 78 79