1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -codegenprepare -S | FileCheck %s
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 @b = dso_local local_unnamed_addr global i64 0, align 8
8 @c = dso_local local_unnamed_addr global i64 0, align 8
9 @d = dso_local local_unnamed_addr global i64 0, align 8
10 @e = dso_local local_unnamed_addr global i64 0, align 8
11 @f = dso_local local_unnamed_addr global i64 0, align 8
12 @g = dso_local local_unnamed_addr global i64 0, align 8
14 define dso_local i32 @m() {
17 ; CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @f, align 8
18 ; CHECK-NEXT: [[TMP1:%.*]] = load i64, ptr @c, align 8
19 ; CHECK-NEXT: [[CONV18:%.*]] = trunc i64 [[TMP1]] to i32
20 ; CHECK-NEXT: [[TMP2:%.*]] = load i64, ptr @d, align 8
21 ; CHECK-NEXT: [[CONV43:%.*]] = trunc i64 [[TMP2]] to i8
22 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
24 ; CHECK-NEXT: [[J_0:%.*]] = phi i32 [ undef, [[ENTRY:%.*]] ], [ [[J_1_LCSSA:%.*]], [[FOR_COND39_PREHEADER:%.*]] ]
25 ; CHECK-NEXT: [[P_0:%.*]] = phi i64 [ undef, [[ENTRY]] ], [ [[P_1_LCSSA:%.*]], [[FOR_COND39_PREHEADER]] ]
26 ; CHECK-NEXT: [[I_0:%.*]] = phi i32 [ undef, [[ENTRY]] ], [ [[I_1_LCSSA:%.*]], [[FOR_COND39_PREHEADER]] ]
27 ; CHECK-NEXT: [[CMP73:%.*]] = icmp slt i32 [[I_0]], 3
28 ; CHECK-NEXT: br i1 [[CMP73]], label [[FOR_BODY:%.*]], label [[FOR_COND39_PREHEADER]]
29 ; CHECK: for.cond1.loopexit:
30 ; CHECK-NEXT: [[TMP3:%.*]] = icmp slt i32 [[CONV18]], 3
31 ; CHECK-NEXT: br i1 [[TMP3]], label [[FOR_BODY]], label [[FOR_COND39_PREHEADER]]
32 ; CHECK: for.cond39.preheader:
33 ; CHECK-NEXT: [[J_1_LCSSA]] = phi i32 [ [[J_0]], [[FOR_COND]] ], [ [[CONV18]], [[FOR_COND1_LOOPEXIT:%.*]] ]
34 ; CHECK-NEXT: [[P_1_LCSSA]] = phi i64 [ [[P_0]], [[FOR_COND]] ], [ 0, [[FOR_COND1_LOOPEXIT]] ]
35 ; CHECK-NEXT: [[I_1_LCSSA]] = phi i32 [ [[I_0]], [[FOR_COND]] ], [ [[CONV18]], [[FOR_COND1_LOOPEXIT]] ]
36 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i8 [[CONV43]], 0
37 ; CHECK-NEXT: br i1 [[TMP4]], label [[FOR_COND]], label [[FOR_INC42:%.*]]
39 ; CHECK-NEXT: [[L_176:%.*]] = phi i8 [ [[SUB:%.*]], [[FOR_COND1_LOOPEXIT]] ], [ 0, [[FOR_COND]] ]
40 ; CHECK-NEXT: [[P_175:%.*]] = phi i64 [ 0, [[FOR_COND1_LOOPEXIT]] ], [ [[P_0]], [[FOR_COND]] ]
41 ; CHECK-NEXT: [[J_174:%.*]] = phi i32 [ [[CONV18]], [[FOR_COND1_LOOPEXIT]] ], [ [[J_0]], [[FOR_COND]] ]
42 ; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq i32 [[J_174]], 0
43 ; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[CLEANUP45:%.*]], label [[FOR_COND2_PREHEADER:%.*]]
44 ; CHECK: for.cond2.preheader:
45 ; CHECK-NEXT: [[DOTPR_PRE:%.*]] = load i64, ptr @e, align 8
46 ; CHECK-NEXT: switch i64 [[P_175]], label [[FOR_BODY4_PREHEADER6:%.*]] [
47 ; CHECK-NEXT: i64 -1, label [[FOR_END12:%.*]]
48 ; CHECK-NEXT: i64 -2, label [[FOR_END12]]
49 ; CHECK-NEXT: i64 -3, label [[FOR_END12]]
50 ; CHECK-NEXT: i64 -4, label [[FOR_END12]]
51 ; CHECK-NEXT: i64 -5, label [[FOR_END12]]
52 ; CHECK-NEXT: i64 -6, label [[FOR_END12]]
53 ; CHECK-NEXT: i64 -7, label [[FOR_END12]]
54 ; CHECK-NEXT: i64 0, label [[FOR_END12]]
56 ; CHECK: for.body4.preheader6:
57 ; CHECK-NEXT: [[TMP5:%.*]] = sub i64 0, [[P_175]]
58 ; CHECK-NEXT: [[XTRAITER:%.*]] = and i64 [[TMP5]], 7
59 ; CHECK-NEXT: [[TMP6:%.*]] = add i64 [[P_175]], [[XTRAITER]]
60 ; CHECK-NEXT: br label [[FOR_BODY4:%.*]]
62 ; CHECK-NEXT: [[P_270:%.*]] = phi i64 [ [[INC11_7:%.*]], [[FOR_BODY4]] ], [ [[TMP6]], [[FOR_BODY4_PREHEADER6]] ]
63 ; CHECK-NEXT: [[INC11_7]] = add i64 [[P_270]], 8
64 ; CHECK-NEXT: [[TOBOOL3_NOT_7:%.*]] = icmp eq i64 [[INC11_7]], 0
65 ; CHECK-NEXT: br i1 [[TOBOOL3_NOT_7]], label [[FOR_END12]], label [[FOR_BODY4]]
67 ; CHECK-NEXT: [[TMP7:%.*]] = inttoptr i64 [[TMP0]] to ptr
68 ; CHECK-NEXT: [[TMP8:%.*]] = load i32, ptr [[TMP7]], align 4
69 ; CHECK-NEXT: [[CONV23:%.*]] = zext i32 [[TMP8]] to i64
70 ; CHECK-NEXT: [[TMP9:%.*]] = load i64, ptr @b, align 8
71 ; CHECK-NEXT: [[DIV24:%.*]] = udiv i64 [[TMP9]], [[CONV23]]
72 ; CHECK-NEXT: store i64 [[DIV24]], ptr @b, align 8
73 ; CHECK-NEXT: [[SUB]] = add i8 [[L_176]], -1
74 ; CHECK-NEXT: [[TOBOOL32_NOT72:%.*]] = icmp eq i64 [[DOTPR_PRE]], 0
75 ; CHECK-NEXT: br i1 [[TOBOOL32_NOT72]], label [[FOR_COND1_LOOPEXIT]], label [[FOR_INC34_PREHEADER:%.*]]
76 ; CHECK: for.inc34.preheader:
77 ; CHECK-NEXT: store i64 0, ptr @e, align 8
78 ; CHECK-NEXT: br label [[FOR_COND1_LOOPEXIT]]
80 ; CHECK-NEXT: br label [[FOR_INC42]]
82 ; CHECK-NEXT: [[CMP13:%.*]] = icmp ne i8 [[L_176]], 0
83 ; CHECK-NEXT: [[CONV16:%.*]] = zext i1 [[CMP13]] to i32
84 ; CHECK-NEXT: ret i32 [[CONV16]]
87 %0 = load i64, ptr @f, align 8
88 %1 = inttoptr i64 %0 to ptr
89 %2 = load i64, ptr @c, align 8
90 %conv18 = trunc i64 %2 to i32
91 %cmp = icmp slt i32 %conv18, 3
92 %3 = load i64, ptr @d, align 8
93 %conv43 = trunc i64 %3 to i8
94 %tobool40.not = icmp eq i8 %conv43, 0
97 for.cond: ; preds = %for.cond39.preheader, %entry
98 %j.0 = phi i32 [ undef, %entry ], [ %j.1.lcssa, %for.cond39.preheader ]
99 %p.0 = phi i64 [ undef, %entry ], [ %p.1.lcssa, %for.cond39.preheader ]
100 %i.0 = phi i32 [ undef, %entry ], [ %i.1.lcssa, %for.cond39.preheader ]
101 %cmp73 = icmp slt i32 %i.0, 3
102 br i1 %cmp73, label %for.body, label %for.cond39.preheader
104 for.cond1.loopexit: ; preds = %for.inc34.preheader, %for.end12
105 br i1 %cmp, label %for.body, label %for.cond39.preheader
107 for.cond39.preheader: ; preds = %for.cond1.loopexit, %for.cond
108 %j.1.lcssa = phi i32 [ %j.0, %for.cond ], [ %conv18, %for.cond1.loopexit ]
109 %p.1.lcssa = phi i64 [ %p.0, %for.cond ], [ 0, %for.cond1.loopexit ]
110 %i.1.lcssa = phi i32 [ %i.0, %for.cond ], [ %conv18, %for.cond1.loopexit ]
111 br i1 %tobool40.not, label %for.cond, label %for.inc42
113 for.body: ; preds = %for.cond, %for.cond1.loopexit
114 %l.176 = phi i8 [ %sub, %for.cond1.loopexit ], [ 0, %for.cond ]
115 %p.175 = phi i64 [ 0, %for.cond1.loopexit ], [ %p.0, %for.cond ]
116 %j.174 = phi i32 [ %conv18, %for.cond1.loopexit ], [ %j.0, %for.cond ]
117 %tobool.not = icmp eq i32 %j.174, 0
118 br i1 %tobool.not, label %cleanup45, label %for.cond2.preheader
120 for.cond2.preheader: ; preds = %for.body
121 %.pr.pre = load i64, ptr @e, align 8
122 switch i64 %p.175, label %for.body4.preheader6 [
123 i64 -1, label %for.end12
124 i64 -2, label %for.end12
125 i64 -3, label %for.end12
126 i64 -4, label %for.end12
127 i64 -5, label %for.end12
128 i64 -6, label %for.end12
129 i64 -7, label %for.end12
130 i64 0, label %for.end12
133 for.body4.preheader6: ; preds = %for.cond2.preheader
134 %4 = sub i64 0, %p.175
135 %xtraiter = and i64 %4, 7
136 %5 = add i64 %p.175, %xtraiter
139 for.body4: ; preds = %for.body4.preheader6, %for.body4
140 %p.270 = phi i64 [ %inc11.7, %for.body4 ], [ %5, %for.body4.preheader6 ]
141 %inc11.7 = add i64 %p.270, 8
142 %tobool3.not.7 = icmp eq i64 %inc11.7, 0
143 br i1 %tobool3.not.7, label %for.end12, label %for.body4
145 for.end12: ; preds = %for.body4, %for.cond2.preheader, %for.cond2.preheader, %for.cond2.preheader, %for.cond2.preheader, %for.cond2.preheader, %for.cond2.preheader, %for.cond2.preheader, %for.cond2.preheader
146 %6 = load i32, ptr %1, align 4
147 %conv23 = zext i32 %6 to i64
148 %7 = load i64, ptr @b, align 8
149 %div24 = udiv i64 %7, %conv23
150 store i64 %div24, ptr @b, align 8
151 %sub = add i8 %l.176, -1
152 %tobool32.not72 = icmp eq i64 %.pr.pre, 0
153 br i1 %tobool32.not72, label %for.cond1.loopexit, label %for.inc34.preheader
155 for.inc34.preheader: ; preds = %for.end12
156 store i64 0, ptr @e, align 8
157 br label %for.cond1.loopexit
159 for.inc42: ; preds = %for.cond39.preheader, %for.inc42
162 cleanup45: ; preds = %for.body
163 %cmp13 = icmp ne i8 %l.176, 0
164 %conv16 = zext i1 %cmp13 to i32