Arthur Eubanks | 54e1bf1 | 2020-09-14 18:23:08 -0700 | [diff] [blame] | 1 | ; RUN: opt -loop-accesses -analyze -enable-new-pm=0 < %s | FileCheck %s |
Sean Silva | 284b032 | 2016-07-07 01:01:53 +0000 | [diff] [blame] | 2 | ; RUN: opt -passes='require<scalar-evolution>,require<aa>,loop(print-access-info)' -disable-output < %s 2>&1 | FileCheck %s |
Adam Nemet | 424edc6 | 2015-07-08 22:58:48 +0000 | [diff] [blame] | 3 | |
| 4 | target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" |
| 5 | |
| 6 | ; We shouldn't quit the analysis if we encounter a pointer without known |
| 7 | ; bounds *unless* we actually need to emit a memcheck for it. (We only |
Adam Nemet | abc794d | 2015-08-11 23:03:09 +0000 | [diff] [blame] | 8 | ; compute bounds for SCEVAddRecs so A[i*i] is deemed not having known bounds.) |
Adam Nemet | 424edc6 | 2015-07-08 22:58:48 +0000 | [diff] [blame] | 9 | ; |
| 10 | ; for (i = 0; i < 20; ++i) |
| 11 | ; A[i*i] *= 2; |
| 12 | |
| 13 | ; CHECK: for.body: |
| 14 | ; CHECK: Report: unsafe dependent memory operations in loop |
| 15 | ; CHECK-NOT: Report: cannot identify array bounds |
Adam Nemet | a2df750 | 2015-11-03 21:39:52 +0000 | [diff] [blame] | 16 | ; CHECK: Dependences: |
Adam Nemet | 424edc6 | 2015-07-08 22:58:48 +0000 | [diff] [blame] | 17 | ; CHECK: Unknown: |
| 18 | ; CHECK: %loadA = load i16, i16* %arrayidxA, align 2 -> |
| 19 | ; CHECK: store i16 %mul, i16* %arrayidxA, align 2 |
| 20 | |
| 21 | define void @f(i16* %a) { |
| 22 | entry: |
| 23 | br label %for.body |
| 24 | |
| 25 | for.body: ; preds = %for.body, %entry |
| 26 | %ind = phi i64 [ 0, %entry ], [ %add, %for.body ] |
| 27 | |
| 28 | %access_ind = mul i64 %ind, %ind |
| 29 | |
| 30 | %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %access_ind |
| 31 | %loadA = load i16, i16* %arrayidxA, align 2 |
| 32 | |
| 33 | %mul = mul i16 %loadA, 2 |
| 34 | |
| 35 | store i16 %mul, i16* %arrayidxA, align 2 |
| 36 | |
| 37 | %add = add nuw nsw i64 %ind, 1 |
| 38 | %exitcond = icmp eq i64 %add, 20 |
| 39 | br i1 %exitcond, label %for.end, label %for.body |
| 40 | |
| 41 | for.end: ; preds = %for.body |
| 42 | ret void |
| 43 | } |