1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -S -passes='print<access-info>' -pass-remarks-analysis=loop-vectorize -disable-output < %s 2>&1 | FileCheck %s
4 ; Test that LoopVectorize don't report 'Use #pragma loop distribute(enable) to allow loop distribution'
5 ; when we already add #pragma clang loop distribute(enable).
7 ; Testcase derived from the following C:
10 ; void foo (int *restrict y, int *restrict x, int *restrict indices, int n)
13 ; #pragma clang loop distribute(enable)
14 ; for (int i = 0; i < n; i++) {
15 ; y[i + k * M] = y[i + k* M] + 1;
16 ; y[i + k * (M+1)] = indices[i] + 2;
20 define void @foo(ptr noalias nocapture noundef %y, ptr noalias nocapture noundef readnone %x, ptr noalias nocapture noundef readonly %indices, i32 noundef %n) {
22 ; CHECK-NEXT: for.body:
23 ; CHECK-NEXT: Report: unsafe dependent memory operations in loop.
24 ; CHECK-NEXT: Backward loop carried data dependence that prevents store-to-load forwarding.
25 ; CHECK-NEXT: Dependences:
26 ; CHECK-NEXT: BackwardVectorizableButPreventsForwarding:
27 ; CHECK-NEXT: %1 = load i32, ptr %arrayidx, align 4 ->
28 ; CHECK-NEXT: store i32 %add8, ptr %arrayidx12, align 4
30 ; CHECK-NEXT: BackwardVectorizable:
31 ; CHECK-NEXT: store i32 %add1, ptr %arrayidx, align 4 ->
32 ; CHECK-NEXT: store i32 %add8, ptr %arrayidx12, align 4
34 ; CHECK-NEXT: Forward:
35 ; CHECK-NEXT: %1 = load i32, ptr %arrayidx, align 4 ->
36 ; CHECK-NEXT: store i32 %add1, ptr %arrayidx, align 4
38 ; CHECK-NEXT: Run-time memory checks:
39 ; CHECK-NEXT: Grouped accesses:
41 ; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
42 ; CHECK-NEXT: SCEV assumptions:
44 ; CHECK-NEXT: Expressions re-written:
47 %cmp22 = icmp sgt i32 %n, 0
48 br i1 %cmp22, label %for.body.preheader, label %for.cond.cleanup
50 for.body.preheader: ; preds = %entry
51 %wide.trip.count = zext i32 %n to i64
54 for.cond.cleanup.loopexit: ; preds = %for.body
55 br label %for.cond.cleanup
57 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
60 for.body: ; preds = %for.body, %for.body.preheader
61 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
62 %0 = add nuw nsw i64 %indvars.iv, 300
63 %arrayidx = getelementptr inbounds i32, ptr %y, i64 %0
64 %1 = load i32, ptr %arrayidx, align 4
65 %add1 = add nsw i32 %1, 1
66 store i32 %add1, ptr %arrayidx, align 4
67 %arrayidx7 = getelementptr inbounds i32, ptr %indices, i64 %indvars.iv
68 %2 = load i32, ptr %arrayidx7, align 4
69 %add8 = add nsw i32 %2, 2
70 %3 = add nuw nsw i64 %indvars.iv, 303
71 %arrayidx12 = getelementptr inbounds i32, ptr %y, i64 %3
72 store i32 %add8, ptr %arrayidx12, align 4
73 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
74 %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
75 br i1 %exitcond.not, label %for.cond.cleanup.loopexit, label %for.body, !llvm.loop !0
78 !0 = distinct !{!0, !1}
79 !1 = !{!"llvm.loop.distribute.enable", i1 true}