safe-no-checks.ll 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. ; RUN: opt -basicaa -loop-accesses -analyze < %s | FileCheck %s
  2. ; If the arrays don't alias this loop is safe with no memchecks:
  3. ; for (i = 0; i < n; i++)
  4. ; A[i] = A[i+1] * B[i] * C[i];
  5. target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
  6. target triple = "x86_64-apple-macosx10.10.0"
  7. ; CHECK: Memory dependences are safe{{$}}
  8. define void @f(i16* noalias %a,
  9. i16* noalias %b,
  10. i16* noalias %c) {
  11. entry:
  12. br label %for.body
  13. for.body: ; preds = %for.body, %entry
  14. %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]
  15. %add = add nuw nsw i64 %ind, 1
  16. %arrayidxA_plus_2 = getelementptr inbounds i16, i16* %a, i64 %add
  17. %loadA_plus_2 = load i16, i16* %arrayidxA_plus_2, align 2
  18. %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %ind
  19. %loadB = load i16, i16* %arrayidxB, align 2
  20. %arrayidxC = getelementptr inbounds i16, i16* %c, i64 %ind
  21. %loadC = load i16, i16* %arrayidxC, align 2
  22. %mul = mul i16 %loadB, %loadA_plus_2
  23. %mul1 = mul i16 %mul, %loadC
  24. %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %ind
  25. store i16 %mul1, i16* %arrayidxA, align 2
  26. %exitcond = icmp eq i64 %add, 20
  27. br i1 %exitcond, label %for.end, label %for.body
  28. for.end: ; preds = %for.body
  29. ret void
  30. }