pointer-with-unknown-bounds.ll 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ; RUN: opt -loop-accesses -analyze < %s | FileCheck %s
  2. target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
  3. ; We shouldn't quit the analysis if we encounter a pointer without known
  4. ; bounds *unless* we actually need to emit a memcheck for it. (We only
  5. ; compute bounds for SCEVAddRecs so A[i*I] is deemed not having known bounds.)
  6. ;
  7. ; for (i = 0; i < 20; ++i)
  8. ; A[i*i] *= 2;
  9. ; CHECK: for.body:
  10. ; CHECK: Report: unsafe dependent memory operations in loop
  11. ; CHECK-NOT: Report: cannot identify array bounds
  12. ; CHECK: Interesting Dependences:
  13. ; CHECK: Unknown:
  14. ; CHECK: %loadA = load i16, i16* %arrayidxA, align 2 ->
  15. ; CHECK: store i16 %mul, i16* %arrayidxA, align 2
  16. define void @f(i16* %a) {
  17. entry:
  18. br label %for.body
  19. for.body: ; preds = %for.body, %entry
  20. %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]
  21. %access_ind = mul i64 %ind, %ind
  22. %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %access_ind
  23. %loadA = load i16, i16* %arrayidxA, align 2
  24. %mul = mul i16 %loadA, 2
  25. store i16 %mul, i16* %arrayidxA, align 2
  26. %add = add nuw nsw i64 %ind, 1
  27. %exitcond = icmp eq i64 %add, 20
  28. br i1 %exitcond, label %for.end, label %for.body
  29. for.end: ; preds = %for.body
  30. ret void
  31. }