1 ; RUN: opt -loop-reduce -S < %s | FileCheck %s
3 ; PR11356: likely wrong code bug
4 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
5 target triple = "x86_64-apple-darwin"
7 @g_66 = global [1 x i32] zeroinitializer, align 4
8 @g_775 = global i32 0, align 4
9 @g_752 = global i32 0, align 4
10 @g_3 = global i32 0, align 4
12 ; Ensure that %div.i.i.us is not hoisted.
14 ; CHECK: for.body.i.i.us:
15 ; CHECK: %div.i.i.i.us
17 define i32 @main() nounwind uwtable ssp {
19 %l_2 = alloca [1 x i32], align 4
20 store i32 0, ptr %l_2, align 4
21 %tmp = load i32, ptr @g_3, align 4
22 %idxprom = sext i32 %tmp to i64
23 %arrayidx1 = getelementptr inbounds [1 x i32], ptr %l_2, i64 0, i64 %idxprom
24 %tmp1 = load i32, ptr %arrayidx1, align 4
25 %conv.i.i = and i32 %tmp1, 65535
26 %tobool.i.i.i = icmp ne i32 %tmp, 0
29 codeRepl.loopexit.us-lcssa: ; preds = %for.body.i.i, %codeRepl5
30 br label %codeRepl.loopexit
32 codeRepl.loopexit: ; preds = %codeRepl.loopexit.us-lcssa.us, %codeRepl.loopexit.us-lcssa
35 codeRepl: ; preds = %codeRepl.loopexit, %entry
36 br i1 %tobool.i.i.i, label %codeRepl.split.us, label %codeRepl.codeRepl.split_crit_edge
38 codeRepl.codeRepl.split_crit_edge: ; preds = %codeRepl
39 br label %codeRepl.split
41 codeRepl.split.us: ; preds = %codeRepl
42 br label %for.cond.i.i.us
44 for.cond.i.i.us: ; preds = %for.inc.i.i.us, %codeRepl.split.us
45 %tmp2 = phi i32 [ 0, %codeRepl.split.us ], [ %add.i.i.us, %for.inc.i.i.us ]
46 br label %codeRepl5.us
48 for.inc.i.i.us: ; preds = %for.body.i.i.us
49 %add.i.i.us = add nsw i32 %tmp2, 1
50 store i32 %add.i.i.us, ptr @g_752, align 4
51 br label %for.cond.i.i.us
53 for.body.i.i.us: ; preds = %codeRepl5.us
54 %div.i.i.i.us = udiv i32 1, %conv.i.i
55 %cmp5.i.i.us = icmp eq i32 %div.i.i.i.us, %tmp2
56 br i1 %cmp5.i.i.us, label %codeRepl.loopexit.us-lcssa.us, label %for.inc.i.i.us
58 codeRepl5.us: ; preds = %for.cond.i.i.us
59 br i1 true, label %codeRepl.loopexit.us-lcssa.us, label %for.body.i.i.us
61 codeRepl.loopexit.us-lcssa.us: ; preds = %codeRepl5.us, %for.body.i.i.us
62 br label %codeRepl.loopexit
64 codeRepl.split: ; preds = %codeRepl.codeRepl.split_crit_edge
65 br label %for.cond.i.i
67 for.cond.i.i: ; preds = %for.inc.i.i, %codeRepl.split
68 %tmp3 = phi i32 [ 0, %codeRepl.split ], [ %add.i.i, %for.inc.i.i ]
71 codeRepl5: ; preds = %for.cond.i.i
72 br i1 true, label %codeRepl.loopexit.us-lcssa, label %for.body.i.i
74 for.body.i.i: ; preds = %codeRepl5
75 %cmp5.i.i = icmp eq i32 0, %tmp3
76 br i1 %cmp5.i.i, label %codeRepl.loopexit.us-lcssa, label %for.inc.i.i
78 for.inc.i.i: ; preds = %for.body.i.i
79 %add.i.i = add nsw i32 %tmp3, 1
80 store i32 %add.i.i, ptr @g_752, align 4
81 br label %for.cond.i.i
83 func_4.exit: ; No predecessors!