xref: /llvm-project/llvm/test/Analysis/LoopAccessAnalysis/select-dependence.ll (revision e636434bdf74cf40071b776ef05aafbf161ce4cd)
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5
2; RUN: opt -passes='print<access-info>' -disable-output 2>&1 < %s | FileCheck %s
3
4define void @test(ptr noalias %x, ptr noalias %y, ptr noalias %z) {
5; CHECK-LABEL: 'test'
6; CHECK-NEXT:    loop:
7; CHECK-NEXT:      Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
8; CHECK-NEXT:  Unsafe indirect dependence.
9; CHECK-NEXT:      Dependences:
10; CHECK-NEXT:        IndirectUnsafe:
11; CHECK-NEXT:            %load = load double, ptr %gep.sel, align 8 ->
12; CHECK-NEXT:            store double %load, ptr %gep.sel2, align 8
13; CHECK-EMPTY:
14; CHECK-NEXT:      Run-time memory checks:
15; CHECK-NEXT:      Grouped accesses:
16; CHECK-EMPTY:
17; CHECK-NEXT:      Non vectorizable stores to invariant address were not found in loop.
18; CHECK-NEXT:      SCEV assumptions:
19; CHECK-EMPTY:
20; CHECK-NEXT:      Expressions re-written:
21;
22entry:
23   %gep.y = getelementptr double, ptr %y, i64 -32
24   br label %loop
25
26loop:
27   %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]
28   %icmp = icmp ule i64 %iv, 32
29   %sel = select i1 %icmp, ptr %x, ptr %gep.y
30   %gep.sel = getelementptr inbounds double, ptr %sel, i64 %iv
31   %load = load double, ptr %gep.sel, align 8
32   %sel2 = select i1 %icmp, ptr %y, ptr %z
33   %gep.sel2 = getelementptr inbounds double, ptr %sel2, i64 %iv
34   store double %load, ptr %gep.sel2, align 8
35   %iv.next = add nuw nsw i64 %iv, 1
36   %exit.cond = icmp eq i64 %iv, 94
37   br i1 %exit.cond, label %exit, label %loop
38
39exit:
40   ret void
41}
42
43; Same as previous test, but with selects replaced by phis in the same block.
44define void @test_phi(ptr noalias %x, ptr noalias %y, ptr noalias %z) {
45; CHECK-LABEL: 'test_phi'
46; CHECK-NEXT:    loop:
47; CHECK-NEXT:      Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
48; CHECK-NEXT:  Unsafe indirect dependence.
49; CHECK-NEXT:      Dependences:
50; CHECK-NEXT:        IndirectUnsafe:
51; CHECK-NEXT:            %load = load double, ptr %gep.sel, align 8 ->
52; CHECK-NEXT:            store double %load, ptr %gep.sel2, align 8
53; CHECK-EMPTY:
54; CHECK-NEXT:      Run-time memory checks:
55; CHECK-NEXT:      Grouped accesses:
56; CHECK-EMPTY:
57; CHECK-NEXT:      Non vectorizable stores to invariant address were not found in loop.
58; CHECK-NEXT:      SCEV assumptions:
59; CHECK-EMPTY:
60; CHECK-NEXT:      Expressions re-written:
61;
62entry:
63   %gep.y = getelementptr double, ptr %y, i64 -32
64   br label %loop
65
66loop:
67   %iv = phi i64 [ %iv.next, %latch ], [ 0, %entry ]
68   %icmp = icmp ule i64 %iv, 32
69   br i1 %icmp, label %if, label %latch
70
71if:
72   br label %latch
73
74latch:
75   %sel = phi ptr [ %x, %if ], [ %gep.y, %loop ]
76   %sel2 = phi ptr [ %y, %if ], [ %z, %loop ]
77   %gep.sel = getelementptr inbounds double, ptr %sel, i64 %iv
78   %load = load double, ptr %gep.sel, align 8
79   %gep.sel2 = getelementptr inbounds double, ptr %sel2, i64 %iv
80   store double %load, ptr %gep.sel2, align 8
81   %iv.next = add nuw nsw i64 %iv, 1
82   %exit.cond = icmp eq i64 %iv, 94
83   br i1 %exit.cond, label %exit, label %loop
84
85exit:
86   ret void
87}
88