xref: /llvm-project/llvm/test/Transforms/LICM/pr42969.ll (revision 80e8f2beeb954f8c241897099bb01b24da400e8a)
1; RUN: opt %s -S -passes=licm | FileCheck %s
2
3define i16 @main(i1 %a_b_mayalias, ptr %a, ptr %b) {
4; CHECK:       scalar.body:
5; CHECK-NEXT:    [[J:%.*]] = phi i64
6; CHECK-NEXT:    [[TMP3:%.*]] = load i16
7; CHECK-NEXT:    [[RESULT:%.*]] = add i16 [[TMP3]], 1
8; CHECK-NEXT:    store i16 [[RESULT]]
9
10entry:
11  br label %outer
12
13outer:                                            ; preds = %scalar.cleanup, %entry
14; 4 = MemoryPhi({entry,liveOnEntry},{scalar.cleanup,2})
15  %i = phi i16 [ 0, %entry ], [ %i.next, %scalar.cleanup ]
16  br i1 %a_b_mayalias, label %scalar.ph, label %vector.ph
17
18vector.ph:                                        ; preds = %outer
19; MemoryUse(4) MayAlias
20  %tmp1 = load i16, ptr %a, align 1, !alias.scope !0, !tbaa !7
21  %tmp2 = add i16 %tmp1, 1
22; 1 = MemoryDef(4)
23  store i16 %tmp2, ptr %b, align 1, !alias.scope !3, !noalias !0, !tbaa !7
24  br label %vector.body
25
26vector.body:                                      ; preds = %vector.body, %vector.ph
27  %index = phi i64 [ %index.next, %vector.body ], [ 0, %vector.ph ]
28  %index.next = add i64 %index, 1
29  %cmp1 = icmp eq i64 %index.next, 16
30  br i1 %cmp1, label %middle.block, label %vector.body
31
32middle.block:                                     ; preds = %vector.body
33  br label %scalar.ph
34
35scalar.ph:                                        ; preds = %middle.block, %outer
36; 5 = MemoryPhi({outer,4},{middle.block,1})
37  %j.start = phi i64 [ 0, %outer ], [ 16, %middle.block ]
38  br label %scalar.body
39
40scalar.body:                                      ; preds = %scalar.body, %scalar.ph
41; 3 = MemoryPhi({scalar.ph,5},{scalar.body,2})
42  %j = phi i64 [ %j.next, %scalar.body ], [ %j.start, %scalar.ph ]
43; MemoryUse(3) MayAlias
44  %tmp3 = load i16, ptr %a, align 1, !tbaa !7
45  %result = add i16 %tmp3, 1
46; 2 = MemoryDef(3)
47  store i16 %result, ptr %b, align 1, !tbaa !7
48  %j.next = add nuw nsw i64 %j, 1
49  %cmp2 = icmp ult i64 %j.next, 20
50  br i1 %cmp2, label %scalar.body, label %scalar.cleanup
51
52scalar.cleanup:                                   ; preds = %scalar.body
53  %result.lcssa = phi i16 [ %result, %scalar.body ]
54  %i.next = add nuw nsw i16 %i, 1
55  %exitcond = icmp eq i16 %i.next, 10
56  br i1 %exitcond, label %exit.block, label %outer
57
58exit.block:                                       ; preds = %scalar.cleanup
59  %result.lcssa.lcssa = phi i16 [ %result.lcssa, %scalar.cleanup ]
60  ret i16 %result.lcssa.lcssa
61}
62
63!0 = !{!1}
64!1 = distinct !{!1, !2}
65!2 = distinct !{!2, !"LVerDomain"}
66!3 = !{!4}
67!4 = distinct !{!4, !2}
68!5 = !{!"Simple C++ TBAA"}
69!6 = !{!"omnipotent char", !5, i64 0}
70!7 = !{!6, !6, i64 0}
71