xref: /llvm-project/polly/test/ScopInfo/reduction_different_index.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly '-passes=print<polly-function-scops>' -disable-output < %s 2>&1 | FileCheck %s
2; Verify if the following case is not detected as reduction.
3;
4; void f(int *A,int *sum) {
5;   for (int i = 0; i < 1024; i++)
6;     sum[0] = sum[1] + A[i];
7; }
8;
9; Verify that we don't detect the reduction on sum
10;
11; CHECK: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
12; CHECK-NEXT: { Stmt_for_body[i0] -> MemRef_sum[1] };
13; CHECK-NEXT:ReadAccess := [Reduction Type: NONE] [Scalar: 0]
14; CHECK-NEXT: { Stmt_for_body[i0] -> MemRef_A[i0] };
15; CHECK-NEXT:MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
16; CHECK-NEXT: { Stmt_for_body[i0] -> MemRef_sum[0] };
17;
18target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
19
20define dso_local void @f(ptr nocapture noundef readonly %A, ptr nocapture noundef %sum) local_unnamed_addr #0 {
21entry:
22  br label %for.body
23
24for.cond.cleanup:                                 ; preds = %for.body
25  ret void
26
27for.body:                                         ; preds = %entry.split, %for.body
28  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
29  %arrayidx = getelementptr inbounds i32, ptr %sum, i64 1
30  %0 = load i32, ptr %arrayidx
31  %arrayidx1 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
32  %1 = load i32, ptr %arrayidx1
33  %add = add nsw i32 %1, %0
34  store i32 %add, ptr %sum
35  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
36  %exitcond.not = icmp eq i64 %indvars.iv.next, 1024
37  br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
38}
39