2 ; RUN: llc -mtriple=arm64-unknown-linux-gnu -debug-only=tailduplication %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=LINUX
3 ; RUN: llc -mtriple=arm64-apple-darwin -debug-only=tailduplication %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=DARWIN
5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7 @g = common local_unnamed_addr global i32 0, align 4
8 @f = common local_unnamed_addr global i32 0, align 4
9 @a = common local_unnamed_addr global i32 0, align 4
10 @m = common local_unnamed_addr global i32 0, align 4
11 @l = common local_unnamed_addr global i32 0, align 4
12 @j = common local_unnamed_addr global i32 0, align 4
13 @k = common local_unnamed_addr global i32 0, align 4
14 @i = common local_unnamed_addr global i32 0, align 4
15 @d = common local_unnamed_addr global i32 0, align 4
16 @c = common local_unnamed_addr global i32 0, align 4
17 @e = common local_unnamed_addr global i32 0, align 4
18 @h = common local_unnamed_addr global i32 0, align 4
20 ; Function Attrs: norecurse nounwind uwtable
21 define void @n(i32 %o, i32* nocapture readonly %b) local_unnamed_addr #0 {
23 %0 = load i32, i32* @g, align 4, !tbaa !2
24 %tobool = icmp eq i32 %0, 0
25 br i1 %tobool, label %entry.if.end_crit_edge, label %if.then
27 entry.if.end_crit_edge: ; preds = %entry
28 %.pre = load i32, i32* @f, align 4, !tbaa !2
31 if.then: ; preds = %entry
32 store i32 0, i32* @f, align 4, !tbaa !2
35 ; DARWIN: Merging into block
36 ; LINUX: Merging into block
38 if.end: ; preds = %entry.if.end_crit_edge, %if.then
39 %1 = phi i32 [ %.pre, %entry.if.end_crit_edge ], [ 0, %if.then ]
40 %cmp6 = icmp slt i32 %1, %o
41 br i1 %cmp6, label %for.body.lr.ph, label %for.end
43 for.body.lr.ph: ; preds = %if.end
44 %.pre7 = load i32, i32* @a, align 4, !tbaa !2
45 %.pre8 = load i32, i32* @l, align 4, !tbaa !2
46 %.pre9 = load i32, i32* @j, align 4, !tbaa !2
47 %.pre10 = load i32, i32* @k, align 4, !tbaa !2
48 %.pre11 = load i32, i32* @i, align 4, !tbaa !2
51 for.body: ; preds = %if.end5, %for.body.lr.ph
52 %2 = phi i32 [ %.pre11, %for.body.lr.ph ], [ %7, %if.end5 ]
53 %3 = phi i32 [ %.pre10, %for.body.lr.ph ], [ %8, %if.end5 ]
54 %4 = phi i32 [ %.pre9, %for.body.lr.ph ], [ %9, %if.end5 ]
55 %5 = phi i32 [ %1, %for.body.lr.ph ], [ %inc, %if.end5 ]
56 store i32 %.pre7, i32* @m, align 4, !tbaa !2
57 %mul = mul nsw i32 %3, %4
58 %cmp1 = icmp sgt i32 %.pre8, %mul
59 %conv = zext i1 %cmp1 to i32
60 %cmp2 = icmp slt i32 %2, %conv
61 br i1 %cmp2, label %if.then4, label %if.end5
63 if.then4: ; preds = %for.body
64 %6 = load i32, i32* @d, align 4, !tbaa !2
65 store i32 %6, i32* @k, align 4, !tbaa !2
66 store i32 %6, i32* @i, align 4, !tbaa !2
67 store i32 %6, i32* @j, align 4, !tbaa !2
70 if.end5: ; preds = %if.then4, %for.body
71 %7 = phi i32 [ %6, %if.then4 ], [ %2, %for.body ]
72 %8 = phi i32 [ %6, %if.then4 ], [ %3, %for.body ]
73 %9 = phi i32 [ %6, %if.then4 ], [ %4, %for.body ]
74 %10 = load i32, i32* @c, align 4, !tbaa !2
75 %idxprom = sext i32 %10 to i64
76 %arrayidx = getelementptr inbounds i32, i32* %b, i64 %idxprom
77 %11 = load i32, i32* %arrayidx, align 4, !tbaa !2
78 %12 = load i32, i32* @e, align 4, !tbaa !2
79 %sub = sub nsw i32 %11, %12
80 store i32 %sub, i32* @h, align 4, !tbaa !2
81 %inc = add nsw i32 %5, 1
82 store i32 %inc, i32* @f, align 4, !tbaa !2
83 %exitcond = icmp eq i32 %inc, %o
84 br i1 %exitcond, label %for.end, label %for.body
86 for.end: ; preds = %if.end5, %if.end
90 attributes #0 = { norecurse nounwind uwtable }
93 !3 = !{!"int", !4, i64 0}