1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=memcpyopt < %s | FileCheck %s
5 source_filename = "test.cpp"
6 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
7 target triple = "aarch64-unknown-linux-android21"
9 define dso_local void @_Z1ml(i64 %e, i1 %arg) {
10 ; CHECK-LABEL: @_Z1ml(
12 ; CHECK-NEXT: [[L:%.*]] = alloca i8, align 1
13 ; CHECK-NEXT: br label [[WHILE_COND:%.*]]
14 ; CHECK: for.cond.while.cond.loopexit_crit_edge.us-lcssa:
15 ; CHECK-NEXT: br label [[WHILE_COND_LOOPEXIT:%.*]]
16 ; CHECK: while.cond.loopexit:
17 ; CHECK-NEXT: [[TMP0:%.*]] = phi ptr [ [[ADD_PTR_I:%.*]], [[FOR_COND_WHILE_COND_LOOPEXIT_CRIT_EDGE_US_LCSSA:%.*]] ], [ [[TMP1:%.*]], [[WHILE_COND]] ]
18 ; CHECK-NEXT: [[I_1_LCSSA:%.*]] = phi ptr [ [[I_2:%.*]], [[FOR_COND_WHILE_COND_LOOPEXIT_CRIT_EDGE_US_LCSSA]] ], [ [[I_0:%.*]], [[WHILE_COND]] ]
19 ; CHECK-NEXT: br label [[WHILE_COND]]
21 ; CHECK-NEXT: [[TMP1]] = phi ptr [ [[L]], [[ENTRY:%.*]] ], [ [[TMP0]], [[WHILE_COND_LOOPEXIT]] ]
22 ; CHECK-NEXT: [[I_0]] = phi ptr [ [[L]], [[ENTRY]] ], [ [[I_1_LCSSA]], [[WHILE_COND_LOOPEXIT]] ]
23 ; CHECK-NEXT: br i1 [[ARG:%.*]], label [[FOR_BODY_LR_PH:%.*]], label [[WHILE_COND_LOOPEXIT]]
24 ; CHECK: for.body.lr.ph:
25 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
27 ; CHECK-NEXT: [[TMP2:%.*]] = phi ptr [ [[TMP1]], [[FOR_BODY_LR_PH]] ], [ [[ADD_PTR_I]], [[IF_END5:%.*]] ]
28 ; CHECK-NEXT: [[I_15:%.*]] = phi ptr [ [[I_0]], [[FOR_BODY_LR_PH]] ], [ [[I_2]], [[IF_END5]] ]
29 ; CHECK-NEXT: [[ADD_PTR_I]] = getelementptr inbounds i8, ptr [[TMP2]], i64 [[E:%.*]]
30 ; CHECK-NEXT: [[TMP3:%.*]] = load i8, ptr [[TMP2]], align 1, !noalias !0
31 ; CHECK-NEXT: [[TMP4:%.*]] = load i8, ptr [[I_15]], align 1, !alias.scope !0
32 ; CHECK-NEXT: store i8 [[TMP4]], ptr [[TMP2]], align 1
33 ; CHECK-NEXT: br label [[_Z1DPCS_L_EXIT:%.*]]
34 ; CHECK: _Z1dPcS_l.exit:
35 ; CHECK-NEXT: br i1 [[ARG]], label [[IF_THEN3:%.*]], label [[IF_END5]]
37 ; CHECK-NEXT: [[ADD_PTR4:%.*]] = getelementptr inbounds i8, ptr [[I_15]], i64 [[E]]
38 ; CHECK-NEXT: br label [[IF_END5]]
40 ; CHECK-NEXT: [[I_2]] = phi ptr [ [[ADD_PTR4]], [[IF_THEN3]] ], [ [[I_15]], [[_Z1DPCS_L_EXIT]] ]
41 ; CHECK-NEXT: br i1 false, label [[FOR_BODY]], label [[FOR_COND_WHILE_COND_LOOPEXIT_CRIT_EDGE_US_LCSSA]]
44 %l = alloca i8, align 1
47 for.cond.while.cond.loopexit_crit_edge.us-lcssa: ; preds = %if.end5
48 br label %while.cond.loopexit
50 while.cond.loopexit: ; preds = %while.cond, %for.cond.while.cond.loopexit_crit_edge.us-lcssa
51 %0 = phi ptr [ %add.ptr.i, %for.cond.while.cond.loopexit_crit_edge.us-lcssa ], [ %1, %while.cond ]
52 %i.1.lcssa = phi ptr [ %i.2, %for.cond.while.cond.loopexit_crit_edge.us-lcssa ], [ %i.0, %while.cond ]
55 while.cond: ; preds = %while.cond.loopexit, %entry
56 %1 = phi ptr [ %l, %entry ], [ %0, %while.cond.loopexit ]
57 %i.0 = phi ptr [ %l, %entry ], [ %i.1.lcssa, %while.cond.loopexit ]
58 br i1 %arg, label %for.body.lr.ph, label %while.cond.loopexit
60 for.body.lr.ph: ; preds = %while.cond
63 for.body: ; preds = %if.end5, %for.body.lr.ph
64 %2 = phi ptr [ %1, %for.body.lr.ph ], [ %add.ptr.i, %if.end5 ]
65 %i.15 = phi ptr [ %i.0, %for.body.lr.ph ], [ %i.2, %if.end5 ]
66 %add.ptr.i = getelementptr inbounds i8, ptr %2, i64 %e
67 %3 = load i8, ptr %2, align 1, !noalias !0
68 %4 = load i8, ptr %i.15, align 1, !alias.scope !0
69 store i8 %4, ptr %2, align 1
70 br label %_Z1dPcS_l.exit
72 _Z1dPcS_l.exit: ; preds = %for.body
73 br i1 %arg, label %if.then3, label %if.end5
75 if.then3: ; preds = %_Z1dPcS_l.exit
76 %add.ptr4 = getelementptr inbounds i8, ptr %i.15, i64 %e
79 if.end5: ; preds = %if.then3, %_Z1dPcS_l.exit
80 %i.2 = phi ptr [ %add.ptr4, %if.then3 ], [ %i.15, %_Z1dPcS_l.exit ]
81 br i1 false, label %for.body, label %for.cond.while.cond.loopexit_crit_edge.us-lcssa
85 !1 = distinct !{!1, !2, !"_Z1dPcS_l: %h"}
86 !2 = distinct !{!2, !"_Z1dPcS_l"}