llvm.org GIT mirror llvm / 46a8736
[Pass Pipeline][NFC] Add a test prior to committing D61726 This patch just adds a test case to show the differences in code emitted by opt before and after https://reviews.llvm.org/D61726. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360426 91177308-0d34-0410-b5e6-96231b3b80d8 Nemanja Ivanovic 4 months ago
1 changed file(s) with 152 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt -O2 -S < %s | FileCheck %s
2 ; RUN: opt -passes='default' -S < %s | FileCheck %s --check-prefix=NPM
3 target datalayout = "e-m:e-i64:64-n32:64"
4 target triple = "powerpc64le-unknown-linux-gnu"
5
6 define dso_local i64 @func(i64 %blah, i64 %limit) #0 {
7 ; CHECK-LABEL: @func(
8 ; CHECK-NEXT: entry:
9 ; CHECK-NEXT: [[CMP4:%.*]] = icmp eq i64 [[LIMIT:%.*]], 0
10 ; CHECK-NEXT: br i1 [[CMP4]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY_LR_PH:%.*]]
11 ; CHECK: for.body.lr.ph:
12 ; CHECK-NEXT: [[CONV:%.*]] = and i64 [[BLAH:%.*]], 4294967295
13 ; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[LIMIT]], -1
14 ; CHECK-NEXT: [[XTRAITER:%.*]] = and i64 [[LIMIT]], 7
15 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i64 [[TMP0]], 7
16 ; CHECK-NEXT: br i1 [[TMP1]], label [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA:%.*]], label [[FOR_BODY_LR_PH_NEW:%.*]]
17 ; CHECK: for.body.lr.ph.new:
18 ; CHECK-NEXT: [[UNROLL_ITER:%.*]] = sub i64 [[LIMIT]], [[XTRAITER]]
19 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
20 ; CHECK: for.cond.cleanup.loopexit.unr-lcssa:
21 ; CHECK-NEXT: [[ADD_LCSSA_PH:%.*]] = phi i64 [ undef, [[FOR_BODY_LR_PH]] ], [ [[ADD_7:%.*]], [[FOR_BODY]] ]
22 ; CHECK-NEXT: [[K_05_UNR:%.*]] = phi i64 [ 1, [[FOR_BODY_LR_PH]] ], [ [[AND:%.*]], [[FOR_BODY]] ]
23 ; CHECK-NEXT: [[LCMP_MOD:%.*]] = icmp eq i64 [[XTRAITER]], 0
24 ; CHECK-NEXT: br i1 [[LCMP_MOD]], label [[FOR_COND_CLEANUP]], label [[FOR_BODY_EPIL:%.*]]
25 ; CHECK: for.body.epil:
26 ; CHECK-NEXT: [[G_06_EPIL:%.*]] = phi i64 [ [[ADD_EPIL:%.*]], [[FOR_BODY_EPIL]] ], [ [[ADD_LCSSA_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ]
27 ; CHECK-NEXT: [[K_05_EPIL:%.*]] = phi i64 [ [[AND_EPIL:%.*]], [[FOR_BODY_EPIL]] ], [ [[K_05_UNR]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ]
28 ; CHECK-NEXT: [[EPIL_ITER:%.*]] = phi i64 [ [[EPIL_ITER_SUB:%.*]], [[FOR_BODY_EPIL]] ], [ [[XTRAITER]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ]
29 ; CHECK-NEXT: [[AND_EPIL]] = and i64 [[CONV]], [[K_05_EPIL]]
30 ; CHECK-NEXT: [[ADD_EPIL]] = add i64 [[AND_EPIL]], [[G_06_EPIL]]
31 ; CHECK-NEXT: [[EPIL_ITER_SUB]] = add i64 [[EPIL_ITER]], -1
32 ; CHECK-NEXT: [[EPIL_ITER_CMP:%.*]] = icmp eq i64 [[EPIL_ITER_SUB]], 0
33 ; CHECK-NEXT: br i1 [[EPIL_ITER_CMP]], label [[FOR_COND_CLEANUP]], label [[FOR_BODY_EPIL]], !llvm.loop !0
34 ; CHECK: for.cond.cleanup:
35 ; CHECK-NEXT: [[G_0_LCSSA:%.*]] = phi i64 [ undef, [[ENTRY:%.*]] ], [ [[ADD_LCSSA_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ], [ [[ADD_EPIL]], [[FOR_BODY_EPIL]] ]
36 ; CHECK-NEXT: ret i64 [[G_0_LCSSA]]
37 ; CHECK: for.body:
38 ; CHECK-NEXT: [[G_06:%.*]] = phi i64 [ undef, [[FOR_BODY_LR_PH_NEW]] ], [ [[ADD_7]], [[FOR_BODY]] ]
39 ; CHECK-NEXT: [[K_05:%.*]] = phi i64 [ 1, [[FOR_BODY_LR_PH_NEW]] ], [ [[AND]], [[FOR_BODY]] ]
40 ; CHECK-NEXT: [[NITER:%.*]] = phi i64 [ [[UNROLL_ITER]], [[FOR_BODY_LR_PH_NEW]] ], [ [[NITER_NSUB_7:%.*]], [[FOR_BODY]] ]
41 ; CHECK-NEXT: [[AND]] = and i64 [[CONV]], [[K_05]]
42 ; CHECK-NEXT: [[ADD:%.*]] = add i64 [[AND]], [[G_06]]
43 ; CHECK-NEXT: [[ADD_1:%.*]] = add i64 [[AND]], [[ADD]]
44 ; CHECK-NEXT: [[ADD_2:%.*]] = add i64 [[AND]], [[ADD_1]]
45 ; CHECK-NEXT: [[ADD_3:%.*]] = add i64 [[AND]], [[ADD_2]]
46 ; CHECK-NEXT: [[ADD_4:%.*]] = add i64 [[AND]], [[ADD_3]]
47 ; CHECK-NEXT: [[ADD_5:%.*]] = add i64 [[AND]], [[ADD_4]]
48 ; CHECK-NEXT: [[ADD_6:%.*]] = add i64 [[AND]], [[ADD_5]]
49 ; CHECK-NEXT: [[ADD_7]] = add i64 [[AND]], [[ADD_6]]
50 ; CHECK-NEXT: [[NITER_NSUB_7]] = add i64 [[NITER]], -8
51 ; CHECK-NEXT: [[NITER_NCMP_7:%.*]] = icmp eq i64 [[NITER_NSUB_7]], 0
52 ; CHECK-NEXT: br i1 [[NITER_NCMP_7]], label [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]], label [[FOR_BODY]]
53 ;
54 ; NPM-LABEL: @func(
55 ; NPM-NEXT: entry:
56 ; NPM-NEXT: [[CMP4:%.*]] = icmp eq i64 [[LIMIT:%.*]], 0
57 ; NPM-NEXT: br i1 [[CMP4]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY_LR_PH:%.*]]
58 ; NPM: for.body.lr.ph:
59 ; NPM-NEXT: [[CONV:%.*]] = and i64 [[BLAH:%.*]], 4294967295
60 ; NPM-NEXT: [[TMP0:%.*]] = add i64 [[LIMIT]], -1
61 ; NPM-NEXT: [[XTRAITER:%.*]] = and i64 [[LIMIT]], 7
62 ; NPM-NEXT: [[TMP1:%.*]] = icmp ult i64 [[TMP0]], 7
63 ; NPM-NEXT: br i1 [[TMP1]], label [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA:%.*]], label [[FOR_BODY_LR_PH_NEW:%.*]]
64 ; NPM: for.body.lr.ph.new:
65 ; NPM-NEXT: [[UNROLL_ITER:%.*]] = sub i64 [[LIMIT]], [[XTRAITER]]
66 ; NPM-NEXT: [[AND_0:%.*]] = and i64 [[CONV]], 1
67 ; NPM-NEXT: br label [[FOR_BODY:%.*]]
68 ; NPM: for.cond.cleanup.loopexit.unr-lcssa:
69 ; NPM-NEXT: [[ADD_LCSSA_PH:%.*]] = phi i64 [ undef, [[FOR_BODY_LR_PH]] ], [ [[ADD_7:%.*]], [[FOR_BODY]] ]
70 ; NPM-NEXT: [[K_05_UNR:%.*]] = phi i64 [ 1, [[FOR_BODY_LR_PH]] ], [ [[AND_PHI:%.*]], [[FOR_BODY]] ]
71 ; NPM-NEXT: [[LCMP_MOD:%.*]] = icmp eq i64 [[XTRAITER]], 0
72 ; NPM-NEXT: br i1 [[LCMP_MOD]], label [[FOR_COND_CLEANUP]], label [[FOR_BODY_EPIL:%.*]]
73 ; NPM: for.body.epil:
74 ; NPM-NEXT: [[G_06_EPIL:%.*]] = phi i64 [ [[ADD_EPIL:%.*]], [[FOR_BODY_EPIL]] ], [ [[ADD_LCSSA_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ]
75 ; NPM-NEXT: [[K_05_EPIL:%.*]] = phi i64 [ [[AND_EPIL:%.*]], [[FOR_BODY_EPIL]] ], [ [[K_05_UNR]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ]
76 ; NPM-NEXT: [[EPIL_ITER:%.*]] = phi i64 [ [[EPIL_ITER_SUB:%.*]], [[FOR_BODY_EPIL]] ], [ [[XTRAITER]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ]
77 ; NPM-NEXT: [[AND_EPIL]] = and i64 [[CONV]], [[K_05_EPIL]]
78 ; NPM-NEXT: [[ADD_EPIL]] = add i64 [[AND_EPIL]], [[G_06_EPIL]]
79 ; NPM-NEXT: [[EPIL_ITER_SUB]] = add i64 [[EPIL_ITER]], -1
80 ; NPM-NEXT: [[EPIL_ITER_CMP:%.*]] = icmp eq i64 [[EPIL_ITER_SUB]], 0
81 ; NPM-NEXT: br i1 [[EPIL_ITER_CMP]], label [[FOR_COND_CLEANUP]], label [[FOR_BODY_EPIL]], !llvm.loop !0
82 ; NPM: for.cond.cleanup:
83 ; NPM-NEXT: [[G_0_LCSSA:%.*]] = phi i64 [ undef, [[ENTRY:%.*]] ], [ [[ADD_LCSSA_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ], [ [[ADD_EPIL]], [[FOR_BODY_EPIL]] ]
84 ; NPM-NEXT: ret i64 [[G_0_LCSSA]]
85 ; NPM: for.body:
86 ; NPM-NEXT: [[G_06:%.*]] = phi i64 [ undef, [[FOR_BODY_LR_PH_NEW]] ], [ [[ADD_7]], [[FOR_BODY_FOR_BODY_CRIT_EDGE:%.*]] ]
87 ; NPM-NEXT: [[AND_PHI]] = phi i64 [ [[AND_0]], [[FOR_BODY_LR_PH_NEW]] ], [ [[AND_1:%.*]], [[FOR_BODY_FOR_BODY_CRIT_EDGE]] ]
88 ; NPM-NEXT: [[NITER:%.*]] = phi i64 [ [[UNROLL_ITER]], [[FOR_BODY_LR_PH_NEW]] ], [ [[NITER_NSUB_7:%.*]], [[FOR_BODY_FOR_BODY_CRIT_EDGE]] ]
89 ; NPM-NEXT: [[ADD:%.*]] = add i64 [[AND_PHI]], [[G_06]]
90 ; NPM-NEXT: [[ADD_1:%.*]] = add i64 [[AND_PHI]], [[ADD]]
91 ; NPM-NEXT: [[ADD_2:%.*]] = add i64 [[AND_PHI]], [[ADD_1]]
92 ; NPM-NEXT: [[ADD_3:%.*]] = add i64 [[AND_PHI]], [[ADD_2]]
93 ; NPM-NEXT: [[ADD_4:%.*]] = add i64 [[AND_PHI]], [[ADD_3]]
94 ; NPM-NEXT: [[ADD_5:%.*]] = add i64 [[AND_PHI]], [[ADD_4]]
95 ; NPM-NEXT: [[ADD_6:%.*]] = add i64 [[AND_PHI]], [[ADD_5]]
96 ; NPM-NEXT: [[ADD_7]] = add i64 [[AND_PHI]], [[ADD_6]]
97 ; NPM-NEXT: [[NITER_NSUB_7]] = add i64 [[NITER]], -8
98 ; NPM-NEXT: [[NITER_NCMP_7:%.*]] = icmp eq i64 [[NITER_NSUB_7]], 0
99 ; NPM-NEXT: br i1 [[NITER_NCMP_7]], label [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]], label [[FOR_BODY_FOR_BODY_CRIT_EDGE]]
100 ; NPM: for.body.for.body_crit_edge:
101 ; NPM-NEXT: [[AND_1]] = and i64 [[CONV]], [[AND_PHI]]
102 ; NPM-NEXT: br label [[FOR_BODY]]
103 ;
104 entry:
105 %blah.addr = alloca i64, align 8
106 %limit.addr = alloca i64, align 8
107 %k = alloca i32, align 4
108 %g = alloca i64, align 8
109 %i = alloca i64, align 8
110 store i64 %blah, i64* %blah.addr, align 8
111 store i64 %limit, i64* %limit.addr, align 8
112 store i32 1, i32* %k, align 4
113 store i64 0, i64* %i, align 8
114 br label %for.cond
115
116 for.cond: ; preds = %for.body, %entry
117 %0 = load i64, i64* %i, align 8
118 %1 = load i64, i64* %limit.addr, align 8
119 %cmp = icmp ult i64 %0, %1
120 br i1 %cmp, label %for.body, label %for.cond.cleanup
121
122 for.cond.cleanup: ; preds = %for.cond
123 %2 = load i64, i64* %g, align 8
124 ret i64 %2
125
126 for.body: ; preds = %for.cond
127 %3 = load i64, i64* %blah.addr, align 8
128 %4 = load i32, i32* %k, align 4
129 %conv = zext i32 %4 to i64
130 %and = and i64 %conv, %3
131 %conv1 = trunc i64 %and to i32
132 store i32 %conv1, i32* %k, align 4
133 %5 = load i32, i32* %k, align 4
134 %conv2 = zext i32 %5 to i64
135 %6 = load i64, i64* %g, align 8
136 %add = add i64 %6, %conv2
137 store i64 %add, i64* %g, align 8
138 %7 = load i64, i64* %i, align 8
139 %inc = add i64 %7, 1
140 store i64 %inc, i64* %i, align 8
141 br label %for.cond
142 }
143
144 ; Function Attrs: argmemonly nounwind
145 declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1
146
147 ; Function Attrs: argmemonly nounwind
148 declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1
149
150 attributes #0 = { "use-soft-float"="false" }
151 attributes #1 = { argmemonly nounwind }