1 ; Test that LICM correctly detects conflicting accesses to memory in deeply
2 ; nested subloops. This works in the legacy PM due to a special retained map of
3 ; alias information for inner loops, and in the new PM it is recomputed for each
6 ; RUN: opt -S -aa-pipeline=basic-aa -passes='require<opt-remark-emit>,loop-mssa(licm)' < %s | FileCheck %s
7 ; RUN: opt -S -passes=licm < %s | FileCheck %s
9 define i32 @test(ptr %a, i64 %n.0, i64 %n.0.0, i64 %n.0.0.0, i64 %n.0.0.0.0) nounwind uwtable readonly {
10 ; CHECK-LABEL: define i32 @test
15 ; CHECK: %b = alloca i32
16 ; CHECK: %c = alloca i32
21 %iv.0 = phi i64 [ %iv.0.next, %l.0.latch ], [ 0, %entry ]
22 %iv.0.next = add i64 %iv.0, 1
23 %exitcond.0 = icmp eq i64 %iv.0.next, %n.0
24 %a.val = load i32, ptr %a
25 store i32 %a.val, ptr %b
26 %c.val = trunc i64 %iv.0 to i32
27 store i32 %c.val, ptr %c
28 br label %l.0.0.header
29 ; CHECK: %[[AV:.*]] = load i32, ptr %a
30 ; CHECK: store i32 %[[AV]], ptr %b
31 ; CHECK: %[[CT:.*]] = trunc i64 {{.*}} to i32
32 ; CHECK: store i32 %[[CT]], ptr %c
36 %iv.0.0 = phi i64 [ %iv.0.0.next, %l.0.0.latch ], [ 0, %l.0.header ]
37 %iv.0.0.next = add i64 %iv.0.0, 1
38 %exitcond.0.0 = icmp eq i64 %iv.0.0.next, %n.0.0
39 br label %l.0.0.0.header
43 %iv.0.0.0 = phi i64 [ %iv.0.0.0.next, %l.0.0.0.header ], [ 0, %l.0.0.header ]
44 %iv.0.0.0.next = add i64 %iv.0.0.0, 1
45 %exitcond.0.0.0 = icmp eq i64 %iv.0.0.0.next, %n.0.0.0
46 call void @llvm.memcpy.p0.p0.i64(ptr %a, ptr %c, i64 4, i1 false)
47 call void @llvm.memcpy.p0.p0.i64(ptr %b, ptr %c, i64 4, i1 false)
48 br i1 %exitcond.0.0.0, label %l.0.0.0.header, label %l.0.0.latch
49 ; CHECK: call void @llvm.memcpy.{{.*}}(ptr %a, ptr %c, i64 4
50 ; CHECK: call void @llvm.memcpy.{{.*}}(ptr %b, ptr %c, i64 4
54 br i1 %exitcond.0.0, label %l.0.0.header, label %l.0.latch
58 %b.val = load i32, ptr %b
59 br i1 %exitcond.0, label %exit, label %l.0.header
60 ; CHECK: %[[BV:.*]] = load i32, ptr %b
64 %result.lcssa = phi i32 [ %b.val, %l.0.latch ]
66 ; CHECK: %[[LCSSA:.*]] = phi i32 [ %[[BV]], %{{.*}} ]
67 ; CHECK: ret i32 %[[LCSSA]]
70 declare void @llvm.memcpy.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1)