Home | History | Annotate | Download | only in LoopAccessAnalysis
      1 ; RUN: opt -loop-accesses -analyze %s  | FileCheck %s
      2 ; RUN: opt -passes='require<scalar-evolution>,require<aa>,loop(print-access-info)' -disable-output  < %s 2>&1 | FileCheck %s
      3 
      4 ; Test that the loop accesses are proven safe in this case.
      5 ; The analyzer uses to be confused by the "diamond" because GetUnderlyingObjects
      6 ; is saying that the two pointers can both points to null. The loop analyzer
      7 ; needs to ignore null in the results returned by GetUnderlyingObjects.
      8 
      9 ; CHECK: Memory dependences are safe with run-time checks
     10 
     11 
     12 ; ModuleID = 'bugpoint-reduced-simplified.bc'
     13 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
     14 target triple = "x86_64-apple-macosx10.11.0"
     15 
     16 ; Function Attrs: ssp uwtable
     17 define void @foo(i1 %cond, i32* %ptr1, i32* %ptr2)  {
     18   br i1 %cond, label %.preheader, label %diamond
     19 
     20 diamond:  ; preds = %.noexc.i.i
     21   br label %.preheader
     22 
     23 .preheader:                                     ; preds = %diamond, %0
     24   %ptr1_or_null = phi i32* [ null, %0 ], [ %ptr1, %diamond ]
     25   %ptr2_or_null = phi i32* [ null, %0 ], [ %ptr2, %diamond ]
     26   br label %.lr.ph
     27 
     28 .lr.ph:                                           ; preds = %.lr.ph, %.preheader
     29   %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 10, %.preheader ]
     30   %indvars.iv.next = add nsw i64 %indvars.iv, -1
     31   %tmp4 = getelementptr inbounds i32, i32* %ptr2_or_null, i64 %indvars.iv.next
     32   %tmp5 = load i32, i32* %tmp4, align 4
     33   %tmp6 = getelementptr inbounds i32, i32* %ptr1_or_null, i64 %indvars.iv.next
     34   store i32 undef, i32* %tmp6, align 4
     35   br i1 false, label %.lr.ph, label %.end
     36 
     37 .end:
     38   ret void
     39 }
     40