1*35f70200SMichael Kruse; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s -check-prefix=SEQUENTIAL
2*35f70200SMichael Kruse; RUN: opt %loadPolly -polly-codegen -polly-ast-detect-parallel -S < %s | FileCheck %s -check-prefix=PARALLEL
3*35f70200SMichael Krusetarget datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
4*35f70200SMichael Kruse
5*35f70200SMichael Kruse; This is a trivially parallel loop. We just use it to ensure that we actually
6*35f70200SMichael Kruse; emit the right information.
7*35f70200SMichael Kruse;
8*35f70200SMichael Kruse; for (i = 0; i < n; i++)
9*35f70200SMichael Kruse;   A[i] = 1;
10*35f70200SMichael Kruse;
11*35f70200SMichael Kruse@A = common global [1024 x i32] zeroinitializer
12*35f70200SMichael Krusedefine void @test-one(i64 %n) {
13*35f70200SMichael Krusestart:
14*35f70200SMichael Kruse  fence seq_cst
15*35f70200SMichael Kruse  br label %loop.header
16*35f70200SMichael Kruse
17*35f70200SMichael Kruseloop.header:
18*35f70200SMichael Kruse  %i = phi i64 [ 0, %start ], [ %i.next, %loop.backedge ]
19*35f70200SMichael Kruse  %exitcond = icmp ne i64 %i, %n
20*35f70200SMichael Kruse  br i1 %exitcond, label %loop.body, label %ret
21*35f70200SMichael Kruse
22*35f70200SMichael Kruseloop.body:
23*35f70200SMichael Kruse  %scevgep = getelementptr [1024 x i32], [1024 x i32]* @A, i64 0, i64 %i
24*35f70200SMichael Kruse  store i32 1, i32* %scevgep
25*35f70200SMichael Kruse  br label %loop.backedge
26*35f70200SMichael Kruse
27*35f70200SMichael Kruseloop.backedge:
28*35f70200SMichael Kruse  %i.next = add nsw i64 %i, 1
29*35f70200SMichael Kruse  br label %loop.header
30*35f70200SMichael Kruse
31*35f70200SMichael Kruseret:
32*35f70200SMichael Kruse  fence seq_cst
33*35f70200SMichael Kruse  ret void
34*35f70200SMichael Kruse}
35*35f70200SMichael Kruse
36*35f70200SMichael Kruse; SEQUENTIAL-LABEL: @test-one
37*35f70200SMichael Kruse; SEQUENTIAL-NOT: !llvm.mem.parallel_loop_access
38*35f70200SMichael Kruse; SEQUENTIAL-NOT: !llvm.access.group
39*35f70200SMichael Kruse; SEQUENTIAL-NOT: !llvm.loop
40*35f70200SMichael Kruse
41*35f70200SMichael Kruse; PARALLEL: @test-one
42*35f70200SMichael Kruse; PARALLEL: store i32 1, i32* %scevgep1, {{[ ._!,a-zA-Z0-9]*}}, !llvm.access.group ![[GROUPID3:[0-9]+]]
43*35f70200SMichael Kruse; PARALLEL:  br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit, !llvm.loop ![[LoopID4:[0-9]+]]
44*35f70200SMichael Kruse
45*35f70200SMichael Kruse
46*35f70200SMichael Kruse; This loop has memory dependences that require at least a simple dependence
47*35f70200SMichael Kruse; analysis to detect the parallelism.
48*35f70200SMichael Kruse;
49*35f70200SMichael Kruse; for (i = 0; i < n; i++)
50*35f70200SMichael Kruse;   A[2 * i] = A[2 * i + 1];
51*35f70200SMichael Kruse;
52*35f70200SMichael Krusedefine void @test-two(i64 %n) {
53*35f70200SMichael Krusestart:
54*35f70200SMichael Kruse  fence seq_cst
55*35f70200SMichael Kruse  br label %loop.header
56*35f70200SMichael Kruse
57*35f70200SMichael Kruseloop.header:
58*35f70200SMichael Kruse  %i = phi i64 [ 0, %start ], [ %i.next, %loop.backedge ]
59*35f70200SMichael Kruse  %exitcond = icmp ne i64 %i, %n
60*35f70200SMichael Kruse  br i1 %exitcond, label %loop.body, label %ret
61*35f70200SMichael Kruse
62*35f70200SMichael Kruseloop.body:
63*35f70200SMichael Kruse  %loadoffset1 = mul nsw i64 %i, 2
64*35f70200SMichael Kruse  %loadoffset2 = add nsw i64 %loadoffset1, 1
65*35f70200SMichael Kruse  %scevgepload = getelementptr [1024 x i32], [1024 x i32]* @A, i64 0, i64 %loadoffset2
66*35f70200SMichael Kruse  %val = load i32, i32* %scevgepload
67*35f70200SMichael Kruse  %storeoffset = mul i64 %i, 2
68*35f70200SMichael Kruse  %scevgepstore = getelementptr [1024 x i32], [1024 x i32]* @A, i64 0, i64 %storeoffset
69*35f70200SMichael Kruse  store i32 %val, i32* %scevgepstore
70*35f70200SMichael Kruse  br label %loop.backedge
71*35f70200SMichael Kruse
72*35f70200SMichael Kruseloop.backedge:
73*35f70200SMichael Kruse  %i.next = add nsw i64 %i, 1
74*35f70200SMichael Kruse  br label %loop.header
75*35f70200SMichael Kruse
76*35f70200SMichael Kruseret:
77*35f70200SMichael Kruse  fence seq_cst
78*35f70200SMichael Kruse  ret void
79*35f70200SMichael Kruse}
80*35f70200SMichael Kruse
81*35f70200SMichael Kruse; SEQUENTIAL-LABEL: @test-two
82*35f70200SMichael Kruse; SEQUENTIAL-NOT: !llvm.mem.parallel_loop_access
83*35f70200SMichael Kruse; SEQUENTIAL-NOT: !llvm.access.group
84*35f70200SMichael Kruse; SEQUENTIAL-NOT: !llvm.loop
85*35f70200SMichael Kruse
86*35f70200SMichael Kruse; PARALLEL: @test-two
87*35f70200SMichael Kruse; PARALLEL: %val_p_scalar_ = load i32, i32* %scevgep, {{[ ._!,a-zA-Z0-9]*}}, !llvm.access.group ![[GROUPID8:[0-9]*]]
88*35f70200SMichael Kruse; PARALLEL: store i32 %val_p_scalar_, i32* %scevgep1, {{[ ._!,a-zA-Z0-9]*}}, !llvm.access.group ![[GROUPID8]]
89*35f70200SMichael Kruse; PARALLEL:  br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit, !llvm.loop ![[LoopID9:[0-9]*]]
90*35f70200SMichael Kruse
91*35f70200SMichael Kruse
92*35f70200SMichael Kruse; PARALLEL: ![[LoopID4]] = distinct !{![[LoopID4]], ![[PARACC5:[0-9]+]]}
93*35f70200SMichael Kruse; PARALLEL: ![[PARACC5]] = !{!"llvm.loop.parallel_accesses", ![[GROUPID3]]}
94*35f70200SMichael Kruse; PARALLEL: ![[LoopID9]] = distinct !{![[LoopID9]], ![[PARACC10:[0-9]+]]}
95*35f70200SMichael Kruse; PARALLEL: ![[PARACC10]] = !{!"llvm.loop.parallel_accesses", ![[GROUPID8]]}
96