xref: /llvm-project/llvm/test/CodeGen/ARM/thumb2-size-reduction-internal-flags.ll (revision bed1c7f061aa12417aa081e334afdba45767b938)
1; RUN: llc %s -o - -verify-machineinstrs | FileCheck %s
2
3target datalayout = "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
4target triple = "thumbv7s-apple-ios8.0.0"
5
6%struct.cells = type { i32, i32, ptr }
7
8@reg_len = external global i32, align 4
9
10; The thumb2 size reduction pass commutes arguments to make the first src of an add the same as the dest.
11; It needs to also move the internal flag when commuting arguments.
12
13; CHECK-LABEL: @simulate
14
15; Function Attrs: nounwind optsize ssp
16define i32 @simulate(i32 %iterations, ptr nocapture %present, double %prob, ptr nocapture readonly %structure) {
17entry:
18  %0 = load i32, ptr @reg_len, align 4, !tbaa !3
19  %sub = add nsw i32 %0, -1
20  %div = sdiv i32 %sub, 31
21  %rem2 = srem i32 %sub, 31
22  %cmp35202 = icmp sgt i32 %rem2, 0
23  br label %for.cond3.preheader
24
25for.cond3.preheader:                              ; preds = %if.end85, %entry
26  %call192 = tail call i32 @lrand48() #2
27  br label %for.cond6.preheader
28
29for.cond34.preheader:                             ; preds = %for.inc30
30  br i1 %cmp35202, label %for.body37, label %for.end73
31
32for.cond6.preheader:                              ; preds = %for.inc30, %for.cond3.preheader
33  %call197 = phi i32 [ %call, %for.inc30 ], [ %call192, %for.cond3.preheader ]
34  %i.0196 = phi i32 [ %inc31, %for.inc30 ], [ 0, %for.cond3.preheader ]
35  %temp.1195 = phi ptr [ %5, %for.inc30 ], [ %present, %for.cond3.preheader ]
36  %savefaulty.0194 = phi i32 [ %add12, %for.inc30 ], [ 0, %for.cond3.preheader ]
37  %savef_free.0193 = phi i32 [ %add11, %for.inc30 ], [ 0, %for.cond3.preheader ]
38  br label %for.body8
39
40for.body8:                                        ; preds = %for.body8, %for.cond6.preheader
41  %randv.0190 = phi i32 [ %call197, %for.cond6.preheader ], [ %shr, %for.body8 ]
42  %j.0189 = phi i32 [ 0, %for.cond6.preheader ], [ %inc, %for.body8 ]
43  %temp.2188 = phi ptr [ %temp.1195, %for.cond6.preheader ], [ %5, %for.body8 ]
44  %savefaulty.1187 = phi i32 [ %savefaulty.0194, %for.cond6.preheader ], [ %add12, %for.body8 ]
45  %savef_free.1186 = phi i32 [ %savef_free.0193, %for.cond6.preheader ], [ %add11, %for.body8 ]
46  %1 = load i32, ptr %temp.2188, align 4, !tbaa !7
47  %add11 = add nsw i32 %1, %savef_free.1186
48  %faulty = getelementptr inbounds %struct.cells, ptr %temp.2188, i32 0, i32 1
49  %2 = load i32, ptr %faulty, align 4, !tbaa !10
50  %add12 = add nsw i32 %2, %savefaulty.1187
51  %next = getelementptr inbounds %struct.cells, ptr %temp.2188, i32 0, i32 2
52  %3 = load ptr, ptr %next, align 4, !tbaa !11
53  %4 = load i32, ptr %3, align 4, !tbaa !7
54  %add14 = add nsw i32 %4, %randv.0190
55  %and = and i32 %add14, 1
56  store i32 %and, ptr %temp.2188, align 4, !tbaa !7
57  %call16 = tail call i32 @lrand48() #2
58  %rem17 = srem i32 %call16, 1000
59  %conv18 = sitofp i32 %rem17 to double
60  %div19 = fdiv double %conv18, 1.000000e+03
61  %cmp20 = fcmp olt double %div19, %prob
62  %xor = zext i1 %cmp20 to i32
63  %randv.1 = xor i32 %xor, %randv.0190
64  %5 = load ptr, ptr %next, align 4, !tbaa !11
65  %faulty25 = getelementptr inbounds %struct.cells, ptr %5, i32 0, i32 1
66  %6 = load i32, ptr %faulty25, align 4, !tbaa !10
67  %add26 = add nsw i32 %randv.1, %6
68  %and27 = and i32 %add26, 1
69  store i32 %and27, ptr %faulty, align 4, !tbaa !10
70  %shr = ashr i32 %randv.0190, 1
71  %inc = add nuw nsw i32 %j.0189, 1
72  %exitcond = icmp eq i32 %inc, 31
73  br i1 %exitcond, label %for.inc30, label %for.body8
74
75for.inc30:                                        ; preds = %for.body8
76  %inc31 = add nuw nsw i32 %i.0196, 1
77  %cmp4 = icmp slt i32 %inc31, %div
78  %call = tail call i32 @lrand48() #2
79  br i1 %cmp4, label %for.cond6.preheader, label %for.cond34.preheader
80
81for.body37:                                       ; preds = %for.body37, %for.cond34.preheader
82  %randv.2207 = phi i32 [ %shr70, %for.body37 ], [ %call, %for.cond34.preheader ]
83  %temp.3205 = phi ptr [ %9, %for.body37 ], [ %5, %for.cond34.preheader ]
84  %.pre220 = getelementptr inbounds %struct.cells, ptr %temp.3205, i32 0, i32 1
85  %next50 = getelementptr inbounds %struct.cells, ptr %temp.3205, i32 0, i32 2
86  %7 = load ptr, ptr %next50, align 4, !tbaa !11
87  %8 = load i32, ptr %7, align 4, !tbaa !7
88  %add52 = add nsw i32 %8, %randv.2207
89  %and53 = and i32 %add52, 1
90  store i32 %and53, ptr %temp.3205, align 4, !tbaa !7
91  %call55 = tail call i32 @lrand48() #2
92  %rem56 = srem i32 %call55, 1000
93  %conv57 = sitofp i32 %rem56 to double
94  %div58 = fdiv double %conv57, 1.000000e+03
95  %cmp59 = fcmp olt double %div58, %prob
96  %xor62 = zext i1 %cmp59 to i32
97  %randv.3 = xor i32 %xor62, %randv.2207
98  %9 = load ptr, ptr %next50, align 4, !tbaa !11
99  %faulty65 = getelementptr inbounds %struct.cells, ptr %9, i32 0, i32 1
100  %10 = load i32, ptr %faulty65, align 4, !tbaa !10
101  %add66 = add nsw i32 %randv.3, %10
102  %and67 = and i32 %add66, 1
103  store i32 %and67, ptr %.pre220, align 4, !tbaa !10
104  %shr70 = ashr i32 %randv.2207, 1
105  br label %for.body37
106
107for.end73:                                        ; preds = %for.cond34.preheader
108  %call74 = tail call i32 @lrand48() #2
109  %11 = load i32, ptr @reg_len, align 4, !tbaa !3
110  %sub75 = add nsw i32 %11, -1
111  %arrayidx76 = getelementptr inbounds i8, ptr %structure, i32 %sub75
112  %12 = load i8, ptr %arrayidx76, align 1, !tbaa !12
113  %cmp78 = icmp eq i8 %12, 49
114  br i1 %cmp78, label %if.then80, label %for.end73.if.end85_crit_edge
115
116for.end73.if.end85_crit_edge:                     ; preds = %for.end73
117  %.pre222 = getelementptr inbounds %struct.cells, ptr %5, i32 0, i32 1
118  br label %if.end85
119
120if.then80:                                        ; preds = %for.end73
121  %13 = load i32, ptr %5, align 4, !tbaa !7
122  %add82 = add nsw i32 %13, %add11
123  %faulty83 = getelementptr inbounds %struct.cells, ptr %5, i32 0, i32 1
124  %14 = load i32, ptr %faulty83, align 4, !tbaa !10
125  %add84 = add nsw i32 %14, %add12
126  br label %if.end85
127
128if.end85:                                         ; preds = %if.then80, %for.end73.if.end85_crit_edge
129  %faulty100.pre-phi = phi ptr [ %.pre222, %for.end73.if.end85_crit_edge ], [ %faulty83, %if.then80 ]
130  %savef_free.5 = phi i32 [ %add11, %for.end73.if.end85_crit_edge ], [ %add82, %if.then80 ]
131  %savefaulty.5 = phi i32 [ %add12, %for.end73.if.end85_crit_edge ], [ %add84, %if.then80 ]
132  %add86 = add nsw i32 %savef_free.5, %call74
133  %and87 = and i32 %add86, 1
134  store i32 %and87, ptr %5, align 4, !tbaa !7
135  %call89 = tail call i32 @lrand48() #2
136  %rem90 = srem i32 %call89, 10000
137  %conv91 = sitofp i32 %rem90 to double
138  %div92 = fdiv double %conv91, 1.000000e+04
139  %cmp93 = fcmp olt double %div92, %prob
140  %xor96 = zext i1 %cmp93 to i32
141  %randv.4 = xor i32 %xor96, %call74
142  %add98 = add nsw i32 %randv.4, %savefaulty.5
143  %and99 = and i32 %add98, 1
144  store i32 %and99, ptr %faulty100.pre-phi, align 4, !tbaa !10
145  br label %for.cond3.preheader
146}
147
148; Function Attrs: optsize
149declare i32 @lrand48()
150
151attributes #2 = { nounwind optsize }
152
153!llvm.module.flags = !{!0, !1}
154!llvm.ident = !{!2}
155
156!0 = !{i32 1, !"wchar_size", i32 4}
157!1 = !{i32 1, !"min_enum_size", i32 4}
158!2 = !{!"clang version 3.7.0 (trunk 236243)"}
159!3 = !{!4, !4, i64 0}
160!4 = !{!"int", !5, i64 0}
161!5 = !{!"omnipotent char", !6, i64 0}
162!6 = !{!"Simple C/C++ TBAA"}
163!7 = !{!8, !4, i64 0}
164!8 = !{!"cells", !4, i64 0, !4, i64 4, !9, i64 8}
165!9 = !{!"any pointer", !5, i64 0}
166!10 = !{!8, !4, i64 4}
167!11 = !{!8, !9, i64 8}
168!12 = !{!5, !5, i64 0}
169