1; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
2; RUN: opt %loadPolly -polly-function-scops -analyze < %s | FileCheck %s
3;
4; CHECK: Reduction Type: NONE
5;
6; Check that we do not mark these accesses as reduction like.
7; We do this for the case the loads are modelt with the same LLVM-IR value and
8; for the case there are different LLVM-IR values.
9;
10;    void f(int *A) {
11;      for (int i = 0; i < 1024; i++)
12;        A[i] = A[i] + A[i];
13;    }
14;
15target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
16
17define void @f_one_load_case(i32* %A) {
18entry:
19  br label %for.cond
20
21for.cond:                                         ; preds = %for.inc, %entry
22  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
23  %exitcond = icmp ne i32 %i.0, 1024
24  br i1 %exitcond, label %for.body, label %for.end
25
26for.body:                                         ; preds = %for.cond
27  %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.0
28  %tmp = load i32, i32* %arrayidx, align 4
29  %add = add nsw i32 %tmp, %tmp
30  %arrayidx2 = getelementptr inbounds i32, i32* %A, i32 %i.0
31  store i32 %add, i32* %arrayidx2, align 4
32  br label %for.inc
33
34for.inc:                                          ; preds = %for.body
35  %inc = add nsw i32 %i.0, 1
36  br label %for.cond
37
38for.end:                                          ; preds = %for.cond
39  ret void
40}
41
42define void @f_two_loads_case(i32* %A) {
43entry:
44  br label %for.cond
45
46for.cond:                                         ; preds = %for.inc, %entry
47  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
48  %exitcond = icmp ne i32 %i.0, 1024
49  br i1 %exitcond, label %for.body, label %for.end
50
51for.body:                                         ; preds = %for.cond
52  %arrayidx = getelementptr inbounds i32, i32* %A, i32 %i.0
53  %tmp = load i32, i32* %arrayidx, align 4
54  %arrayidxCopy = getelementptr inbounds i32, i32* %A, i32 %i.0
55  %tmpCopy = load i32, i32* %arrayidxCopy, align 4
56  %add = add nsw i32 %tmp, %tmpCopy
57  %arrayidx2 = getelementptr inbounds i32, i32* %A, i32 %i.0
58  store i32 %add, i32* %arrayidx2, align 4
59  br label %for.inc
60
61for.inc:                                          ; preds = %for.body
62  %inc = add nsw i32 %i.0, 1
63  br label %for.cond
64
65for.end:                                          ; preds = %for.cond
66  ret void
67}
68