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