Home | History | Annotate | Download | only in BasicAA
      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, i32* @Z, align 4
     29   store i32 123, i32* %P, align 4
     30   %tmp2 = load i32, 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 ; CHECK: NoAlias: i32* %arrayidx13, i32* %arrayidx5
     43 
     44 define i32 @pr18068(i32* %jj7, i32* %j) {
     45 entry:
     46   %oa5 = alloca [100 x i32], align 16
     47   br label %codeRepl
     48 
     49 codeRepl:
     50   %0 = phi i32* [ %arrayidx13, %for.body ], [ %j, %entry ]
     51   %targetBlock = call i1 @cond(i32* %jj7)
     52   br i1 %targetBlock, label %for.body, label %bye
     53 
     54 for.body:
     55   %1 = load i32, i32* %jj7, align 4
     56   %idxprom4 = zext i32 %1 to i64
     57   %arrayidx5 = getelementptr inbounds [100 x i32], [100 x i32]* %oa5, i64 0, i64 %idxprom4
     58   %2 = load i32, i32* %arrayidx5, align 4
     59   %sub6 = sub i32 %2, 6
     60   store i32 %sub6, i32* %arrayidx5, align 4
     61   ; %0 and %arrayidx5 can alias! It is not safe to DSE the above store.
     62   %3 = load i32, i32* %0, align 4
     63   store i32 %3, i32* %arrayidx5, align 4
     64   %sub11 = add i32 %1, -1
     65   %idxprom12 = zext i32 %sub11 to i64
     66   %arrayidx13 = getelementptr inbounds [100 x i32], [100 x i32]* %oa5, i64 0, i64 %idxprom12
     67   call void @inc(i32* %jj7)
     68   br label %codeRepl
     69 
     70 bye:
     71   %.reload = load i32, i32* %jj7, align 4
     72   ret i32 %.reload
     73 }
     74 
     75 declare i1 @cond(i32*)
     76 
     77 declare void @inc(i32*)
     78 
     79 
     80