xref: /llvm-project/polly/test/CodeGen/annotated_alias_scopes.ll (revision 4b3a878e8a24c13f8dc435e91304d8692d8cb42b)
1; RUN: opt %loadNPMPolly -passes=polly-codegen -S < %s | FileCheck %s --check-prefix=SCOPES
2;
3; Check that we create alias scopes that indicate the accesses to A, B and C cannot alias in any way.
4;
5; SCOPES-LABEL: polly.stmt.for.body:
6; SCOPES:      %[[BIdx:[._a-zA-Z0-9]*]] = getelementptr{{.*}} ptr %B, i64 %{{.*}}
7; SCOPES:      load i32, ptr %[[BIdx]], align 4, !alias.scope !2, !noalias !5
8; SCOPES:      %[[CIdx:[._a-zA-Z0-9]*]] = getelementptr{{.*}} ptr %C, i64 %{{.*}}
9; SCOPES:      load float, ptr %[[CIdx]], align 4, !alias.scope !8, !noalias !9
10; SCOPES:      %[[AIdx:[._a-zA-Z0-9]*]] = getelementptr{{.*}} ptr %A, i64 %{{.*}}
11; SCOPES:      store i32 %{{[._a-zA-Z0-9]*}}, ptr %[[AIdx]], align 4, !alias.scope !10, !noalias !11
12;
13; SCOPES: !0 = distinct !{!0, !1}
14; SCOPES: !1 = !{!"llvm.loop.vectorize.enable", i32 0}
15; SCOPES: !2 = !{!3}
16; SCOPES: !3 = distinct !{!3, !4, !"polly.alias.scope.MemRef_B"}
17; SCOPES: !4 = distinct !{!4, !"polly.alias.scope.domain"}
18; SCOPES: !5 = !{!6, !7}
19; SCOPES: !6 = distinct !{!6, !4, !"polly.alias.scope.MemRef_C"}
20; SCOPES: !7 = distinct !{!7, !4, !"polly.alias.scope.MemRef_A"}
21; SCOPES: !8 = !{!6}
22; SCOPES: !9 = !{!3, !7}
23; SCOPES: !10 = !{!7}
24; SCOPES: !11 = !{!3, !6}
25;
26;    void jd(int *A, int *B, float *C) {
27;      for (int i = 0; i < 1024; i++)
28;        A[i] = B[i] + C[i];
29;    }
30;
31target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
32
33define void @jd(ptr %A, ptr %B, ptr %C) {
34entry:
35  br label %for.cond
36
37for.cond:                                         ; preds = %for.inc, %entry
38  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
39  %exitcond = icmp ne i64 %indvars.iv, 1024
40  br i1 %exitcond, label %for.body, label %for.end
41
42for.body:                                         ; preds = %for.cond
43  %arrayidx = getelementptr inbounds i32, ptr %B, i64 %indvars.iv
44  %tmp = load i32, ptr %arrayidx, align 4
45  %conv = sitofp i32 %tmp to float
46  %arrayidx2 = getelementptr inbounds float, ptr %C, i64 %indvars.iv
47  %tmp1 = load float, ptr %arrayidx2, align 4
48  %add = fadd fast float %conv, %tmp1
49  %conv3 = fptosi float %add to i32
50  %arrayidx5 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
51  store i32 %conv3, ptr %arrayidx5, align 4
52  br label %for.inc
53
54for.inc:                                          ; preds = %for.body
55  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
56  br label %for.cond
57
58for.end:                                          ; preds = %for.cond
59  ret void
60}
61